OS X Spotlight: kMDItemTextContent of text/csv

14.03.2008 – 11:47

Don’t ask me why, but Leopard’s Spotlight doesn’t want to import the content of csv-files:


galahad:~ hessi$ mdimport -d 2 test.csv
2008-03-14 10:48:02.605 mdimport[2804:10b] Imported '/Users/hessi/test.csv' of type 'dyn.ah62d4rv4ge80g650' with no plugIn.

Consequently, it doesn’t generate the kMDItemTextContent entry.

Simply adding the filetype public.csv to Root/CFBundleDocumentTypes/0/LSItemContentTypes/ in System/Library/Spotlight/RichText.mdimporter doesn’t work, because (TADA!):


galahad:~ hessi$ GetFileInfo -t ~/test.csv
""
galahad:~ hessi$

So, after setting the “correct” filetype:


galahad:~ hessi$ SetFile -t "TEXT" test.csv
galahad:~ hessi$ GetFileInfo -t test.csv
"TEXT"
galahad:~ hessi$

Spotlight finds a plugin to use and even some kMDItemTextContent:


galahad:~ hessi$ mdimport -d 2 test.csv
(Info) Import: Import '/Users/hessi/test.csv' type 'dyn.ah62d4um4ge80g650' using '/System/Library/Spotlight/RichText.mdimporter'
2008-03-14 11:35:16.576 mdimport[3114:10b] Imported '/Users/hessi/test.csv' of type 'dyn.ah62d4um4ge80g650' with plugIn /System/Library/Spotlight/RichText.mdimporter.
2008-03-14 11:35:16.579 mdimport[3114:10b] Attributes: {
"_kMDItemFinderLabel" = ;
“com_apple_metadata_modtime” = 227183678;
kMDItemAuthors = ;
kMDItemComment = ;
kMDItemContentCreationDate = 2008-03-14 11:34:38 +0100;
kMDItemContentModificationDate = 2008-03-14 11:34:38 +0100;
kMDItemContentType = “dyn.ah62d4um4ge80g650″;
kMDItemContentTypeTree = (
“com.apple.traditional-mac-plain-text”,
“public.plain-text”,
“public.text”,
“public.data”,
“public.item”,
“public.content”
);
kMDItemCopyright = ;
kMDItemCreator = ;
kMDItemDisplayName = {
“” = “test.csv”;
};
kMDItemEditors = ;
kMDItemKeywords = ;
kMDItemKind = {
“” = PlainTextType;
de = “Reine Text-Datei”;
en = “Plain Text File”;
};
kMDItemOrganizations = ;
kMDItemSubject = ;
kMDItemTextContent = “value1;value2;value3;value4;value5;\nvalue1;value2;value3;value4;value5″;
kMDItemTitle = ;
}
galahad:~ hessi$

So, next question - why is the File Type of these files not “TEXT”? This csv was copied from a Windows machine, but even files created by SubEthaEdit have an interesting file type:


galahad:~ hessi$ GetFileInfo -t test_see.csv
"****"
galahad:~ hessi$

Post a Comment