Coder Social home page Coder Social logo

quicklook-csv's Introduction

A QuickLook Plugin for CSV Files

Quick look CSV files for Mac OS X 10.5 and newer. Supports files separated by comma (,), tabs (), semicolons (;) pipes (|). The plugin will generate Icons and show a preview, along with some information (like num rows/columns). Many thanks to Ted Fischer for valuable input and testing of version 1.1!

Installation

In order to use this Plugin, download QuickLookCSV.dmg, open it by double-clicking and in there you will find the actual Plugin named QuickLookCSV.qlgenerator.

Place the Plugin into ~/Library/QuickLook/ to install it for yourself only, or into (Macintosh HD)/Library/QuickLook/ to install it for all users of your Mac. If the QuickLook-folder does not exist, simply create it manually. There are aliases to these directories in the disk image you have just downloaded, so you might be able to just drag the plugin onto one of the two aliases to install.

Contributing

If you're interested in contributing, fork the repo and send me a pull request via GitHub.

File Maker TSV Files

Some hacks were made in earlier versions to support FileMaker tab-separated-value files. Those hacks have been removed in Version 1.3. If this means your files no longer preview correctly, download version 1.2 again, but please let me know.

Screenshots

Icons Preview

License

This work is Apache 2 licensed: NOTICE.txt.

quicklook-csv's People

Contributors

kkdd avatar p2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quicklook-csv's Issues

Stop creating an icon for every 'TEXT' file

Original author: [email protected] (September 11, 2010 12:10:51)

Files edited with TextWrangler, which adds a 'TEXT' file type them, that do not have a common text file extension (such as .CUE) keep being identified by the Finder and Quicklook as CSV files. The icon that quicklook-csv creates does not apply, and Quicklook preview gets broken for them (since it tries to parse them as CSV).

CSV or TSV are obviously identified by their extension. For the love of god, limit quicklook-csv to those files with appropriate file name, and nothing else.

What steps will reproduce the problem?

  1. Create a text file, and assign it the .CUE file extension.
  2. Assign it the legacy filetype 'TEXT'. You can do so with A Better Finder Attibutes or editing and saving it with TextWrangler.
  3. Browse with the Finder to that folder, choose column view.
  4. Press spacebar to see the Quiclook preview

What is the expected output? What do you see instead?

In step 3 the icon reads CUE over CSV, and shows the file contents.
In step 4 quicklook-csv renders the contents into rows trying to parse them as CSV.

Neither step 3 nor step 4 should have anything to do with quicklook-csv

What version of the product are you using? On what operating system?

quicklook-csv 1.1.1 on Mac OS X 10.6.4

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=5

More delimiters like semicolon

Hi.
I like this addon and use it quite often.
However, I have lots of csv file using the semicolon (;) as delimiter.
As I'm not very familar with C nor having a compiler, would it be possible to add the semiolon as delimiter too, or make it user configurable at all ?

Thx
Wolfgang

Cross-Site Scripting (XSS) vulnerability

If a CSV file contains HTML and/or JavaScript, the QuickLook-CSV plugin will render it instead of displaying it as simple text. This makes it vulnerable to an XSS which would allow remote attackers to execute arbitrary JavaScript code on the victim's laptop.

Since this is a security issue, feel free to reach out to me on Twitter @JR0ch17 if you have any questions or want more details.

TAB Delimited file support does not work for files with .tab extension

Original author: [email protected] (March 01, 2010 04:52:40)

What steps will reproduce the problem?

  1. Save tab delimited file as file.tab
  2. Attempt quicklook

What is the expected output? What do you see instead?

Quicklook does not work on .tab files. The files are displayed as they
would appear in any text editor, not in a grid format.

What version of the product are you using? On what operating system?

Latest version of quicklook-csv, on os x 10.6.2

Please provide any additional information below.

If the tab delimited file is saved as file.csv, quicklook then works as
expected.

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=3

changing QuickLookCSV's trying encoding

Hello,
I would like to set the QuickLookCSV's trying encoding by
$ defaults write com.google.code.quicklookcsv textEncoding Shift_JIS ,
for example.

The source then would be modified as like this:

OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
:
:
    // We could not open the file, probably unknown encoding; try ISO-8859-1
    if (!fileString) {
-      stringEncoding = NSISOLatin1StringEncoding;
+      stringEncoding = getDefaultEncoding();
      fileString = [NSString stringWithContentsOfURL:myURL encoding:stringEncoding error:&theErr];
:
:
}

+ NSStringEncoding getDefaultEncoding()
+ {
+     NSString *enc_name = [NSUserDefaults.standardUserDefaults stringForKey:@"textEncoding"];
+     CFStringEncoding cf_enc = CFStringConvertIANACharSetNameToEncoding((CFStringRef)enc_name);
+     if (cf_enc == kCFStringEncodingInvalidId) {
+         return NSISOLatin1StringEncoding; // ISO-8859-1
+     }
+     return CFStringConvertEncodingToNSStringEncoding(cf_enc);
+ }

Feature Request: + as a delimiter

Great plugin BTW.

Could the plus symbol "+" be added as an additional delimiter for csv files recognized by the plugin? Is this user-configurable? Thx

QuickLookCSV renders wrong amount of columns under certain circumstances

Original author: [email protected] (September 05, 2012 13:54:11)

APPLICATION / ENVIRONMENT:
I download connection-log-files from my mobile network operator.
Previously the QuickLook preview for that files worked fine.

Recently they changed the format.
Previously there was a header of 7 rows before the real data begins.
In the most recent version there are 8 preceding lines.

BUG DESCRIPTION:
Now the preview of that files renders the wrong amount of columns (2 instead of 13).

WORKAROUND:
Delete the 1 additional line in a text editor (line 8), then it is shown correct. But I'd like to keep that line for completeness (the due date of my bill).

FURTHER PERFORMED TESTS & LOGICAL CONCLUSION ATTEMPTS:
It you remove the linebreak between line 7 and 8 the bug still occurs. But if you remove a certain amount of characters in that line, it suddenly renders the correct amount of columns!
No explanation comes to my mind for that behavior (as I don't know the code behind).

SUBMITTED MATERIAL:
I opened the original file in an hex editor and redacted private info and kept only 3 sample lines, as this is enough for the bug demonstration.
I created a duplicate of this, and modified it until the preview was correct.
Attached are all file states and screenshots of them.

VERSION:
I am using Mac OS X 10.6.8 but I am not sure which version of QuickLookCSV I am using, as the Finder info and the web site info contradict each other.

Website: 1.1.1 ( http://code.google.com/p/quicklook-csv/downloads/detail?name=QuickLookCSV.dmg&can=2&q= )
Finder > file info for .qlgenerator bundle > version: 1.
DMG SHA1: efef48e1bfba02d780a57fa67b230fae53ae6163 (remote and local copy match)
DMG file size: 59.806 bytes
.qlgenerator bundle size: 145.101 bytes

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=11

feature request: lazy load

Sometimes the data csv file is too huge to open, but I just want to shoot a glance at the data structure.

So, maybe it's a good idea to lazy load the full data when csv file is detected as a huge file ~

Crash when previewing small files

Original author: reeves.87 (November 28, 2010 15:17:19)

What steps will reproduce the problem?

  1. Attempt to preview a file < 1024 bytes in size

What is the expected output? What do you see instead?
Should generate a preview or fail gracefully. Causes a stack overflow after leaving formatFilesize.

What version of the product are you using? On what operating system?
10.6.5

Please provide any additional information below.

The attached patch bumps the buffer sizes for formatString and result up by one to account for the null byte at the end of every c string.

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=8

Blank columns incorrectly merged

Original author: Sales%[email protected] (September 15, 2010 13:35:33)

What steps will reproduce the problem?

  1. Create a TSV file with 3 columns, the first two blank and the third with content
  2. View file using quicklook

What is the expected output? What do you see instead?

Only see 3 columns instead of two

What version of the product are you using? On what operating system?

Lastest release, OS X 10.6

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=6

csv preview (thumbnail preview) causes quicklookd to crash

Original author: [email protected] (November 19, 2010 16:10:51)

What steps will reproduce the problem?

  1. Install QuickLook plugin
  2. Open folder containing *.csv files
  3. Check console output for crash

What is the expected output? What do you see instead?
Expect no crash of quicklookd

What version of the product are you using? On what operating system?
1.1.1 on 10.5.6

Please provide any additional information below.
Thumbnailing, previews do work successfully

I have attached crash reporter file and crash history file

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=7

missing support for pipe separated files

Original author: [email protected] (April 06, 2010 06:42:38)

Hi,

thank you very much for this quicklook extension, it was a long awaited one for me! Unfortunately
it is nearly useless for me, because we do separate our csv files with pipes. This results in better
readability and prevents conflicts with comma separated numbers. At least here in germany it is
usual practice.

Could you please support csv files with following structure (i know it's no standard ...):

field 1|field 2|field 3

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=4

[patch] Stop using dynamic UTIs and instead import the standard/system UTIs

Original author: smokey.ardisson (January 03, 2013 03:08:43)

QuickLookCSV (v1.2)'s current plist references both CSV and TSV files with various dynamic UTIs that have been created on various users' Macs over time. This is bad because

  1. the dynamic UTI used on a given Mac might not be in the list of UTIs in the generator's plist, causing the generator not to preview the file, and
  2. a dynamic UTI in use on a given Mac for some other file type might match one of the UTIs listed in the generator's plist, causing the generator to try (and fail) to generate a preview for a file it doesn't understand.

Also, 3) the current .plist double-declares TSV, the second time around claiming that a TSV can be any file that is a traditional plain-text file (com.apple.traditional-mac-plain-text), which causes the generator to be called for any plain-text file, which produces less-than-desirable results for almost all plain-text files.

Instead, the generator should import[1] the standard and/or system-provided UTIs so that the proper UTIs are available on any Mac with the generator installed, regardless of the OS, and then only reference the standard UTIs when declaring supported file types in the CFBundleDocumentTypes keys.

I've had the CFBundleDocumentTypes cleanup hacked into my copy of v1.2 since October, when I ran into all three issues described in the first two paragraphs.

I mostly encounter .tsv files, but today I realized my .csv files weren't previewing and discovered they had dynamic UTIs. So I added the UTImportedTypeDeclarations array to the generator's plist. I then moved the generator from ~/Library/QuickLook to the Desktop, then back (to cause LaunchServices to reparse the updated plist), and then ran qlmanage -r to make quicklookd update the generators. With those changes, Spotlight (mdls) now reports that old and new .csv files now[2] have a UTI of public.comma-separated-values-text, and .csv files finally preview as expected using the generator.

Note this is tested on 10.5, which has no system-provided UTIs for CSV and TSV files; simply importing the declarations in the generator's plist and causing LaunchServices and Quick Look to update themselves after updating the plist is sufficient to get this working without the random dynamic UTIs, while not regressing 10.5.

I'm attaching a diff of my changes, which can be grouped as follows:

  1. Flesh out the CFBundleDocumentTypes with MIME types for both CSV and TSV
  2. Remove dynamic UTIs from CFBundleDocumentTypes for both CSV and TSV
  3. Remove second TSV section from CFBundleDocumentTypes
  4. Add UTImportedTypeDeclarations, with declarations for both CSV and TSV

1 and 3 are what I'd call "optional" changes; 2 and 4 are the core changes that fix the "missing UTI" problem.

I don't have any FileMaker .tab files (Issue 5 comment 9), but I don't see why, if they have the right extension (.tab/.tsv), they would not be handled correctly by the initial TSV section in CFBundleDocumentTypes. Even if for some reason they do need the any-plain-text-file-type com.apple.traditional-mac-plain-text UTI, that UTI still should be added to the main TSV section in CFBundleDocumentTypes instead of creating an extra, almost-duplicate TSV section. At any rate, if in the absence of test files for this change, you want to be extra-cautious to not regress them and therefore omit change 3, it's not the end of the world. It's not ideal, but it's still easy enough for people to delete that extra section or the com.apple.traditional-mac-plain-text UTI and get LaunchServices and quicklookd to take note.

[1] https://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_declare/understand_utis_declare.html#//apple_ref/doc/uid/TP40001319-CH204-SW2

[2] New files get the correct UTI on creation/download; old files don't get the new UTI until they're moved or updated, but they now preview correctly regardless of UTI (and mdimport correctly decides old files should have the new UTI if you attempt to reimport).

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=12

Plugins (User) links to dev's home folder

/Volumes/QuickLook CSV ❯ ls -l                                                                                                                                                                     
-rw-r--r--  1 David  staff   1.1K Feb  2  2013 INSTALL.rtf
lrwxr-xr-x  1 David  staff    18B Feb  2  2013 Plugins (System Wide) -> /Library/QuickLook
lrwxr-xr-x  1 David  staff    27B Feb  2  2013 Plugins (User) -> /Users/pp/Library/QuickLook
drwxr-xr-x  3 David  staff   102B Feb  2  2013 QuickLookCSV.qlgenerator
drwxr-xr-x  6 David  staff   204B Feb  2  2013 Test Files

/Users/pp/ is a broken link. Is not possible to dynamically link to ~/Library/QuickLook?

Niciety: a few test.csv files to play with on .dmg

Original author: [email protected] (September 26, 2011 00:52:41)

What steps will reproduce the problem?

  1. download .dmg
  2. run openssh sha1 against .dmg to validate
  3. mount .dmg

What is the expected output? What do you see instead?
Expected: to see window of test .csv's like the ones on the desktop on project page.

What version of the product are you using? On what operating system?
1.1.1

Please provide any additional information below.

Original issue: http://code.google.com/p/quicklook-csv/issues/detail?id=10

ALE file extension

Would you be willing to add support for files with an ALE extension? This is Avid Log Exchange — simple tab delimited text files with a few header lines, common in the film industry.
Here is an example: https://dl.dropboxusercontent.com/u/33335399/A002R6OW_AVID.ale

Or is it possible for me to add this function myself? I tried editing the Info.plist, but I don't really know what I'm doing here.

File extensions are ignored

Take these two files as an example:

foo.tsv

a,b,c

foo.csv

a	b	c

  • using QuickLook on foo.tsv yields Comma-Separated, UTF-8.
  • using QuickLook on foo.csv yields Tab-Separated, UTF-8.

It seems that the file extension is ignored and the format is automatically detected.

More generally (regardless of file extension), it seems that a file is detected as tab-delimited only when the amount of tab characters is greater than the amount of commas. Otherwise, it is detected as comma-delimited.

Also, the .tab file extension does not seem to trigger this plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.