appending to csv creates new and different headers

Started by RPRIETO, May 18, 2017, 01:43:57 PM

Previous topic - Next topic

RPRIETO

OS: W7P 64 bit
ExifTools: 10.5.3

Before anything else: AMAZING tool. We will be using it to extract meta data from pictures provided by volunteers for cetacean research. ExifTool will save us weeks of work. Can't thank you enough.

I downloaded the tool today and am trying to get a grip on the scripting. From the very good documentation andd some search in the forum, was able to put together a line that does almost everything we need right now, using a bat file.

the code right now reads: exiftool -ext jpg -a -u -g1 -n -csv %* >> C:\Users\[...]\exif_out.csv

The only thing I cannot get right is appending new data to the csv. The data is appended but new 'headers' are created and the order and number of tags are not the same. I am using pictures taken with the same equipment (a DJI drone) separated in different folders, so I assume the tags should be the same?

I am attaching a reference csv.

Does anyone have an idea about correcting that?

thank you for any suggestions,

Rui


RPRIETO

Oh, I forgot; I understand that if I drag/drop several folders simultaneously, the csv come up nicely and with only one header line. However, we will have to do append new information overtime, thus this is not a practical solution.

r

StarGeek

Quote from: RPRIETO on May 18, 2017, 01:43:57 PMThe data is appended but new 'headers' are created and the order and number of tags are not the same. I am using pictures taken with the same equipment (a DJI drone) separated in different folders, so I assume the tags should be the same?

I don't believe there's an option to remove the csv header.    Since you're on windows, you could pipe it through findstr  to remove the first line like this exiftool -csv FileOrDir |findstr /V /R "^SourceFile" >>output.csv but you couldn't do that on the first run because then you wouldn't have any headers at all.  So you'd have to add a check to see if the csv file exists. 
if exist C:\Users\[...]\exif_out.csv (
    exiftool -ext jpg -a -u -g1 -n -csv %* |findstr /V /R "^SourceFile" >> C:\Users\[...]\exif_out.csv
) else (
    exiftool -ext jpg -a -u -g1 -n -csv %*  >> C:\Users\[...]\exif_out.csv
)

But that still doesn't solve the problem of the different number of tags.

Are you using any other program to edit these files first?  In at least one case you used Exiv2 or a program that used Exiv2 library, but not on any other file (C:/Users/rprieto/Desktop/dji14apr2017/DJI_0006.JPG).  This may introduce other tags.

My suggestion would be to figure out what tags you actually need, since it seems unlikely you need them all.  For example, the binary data tags (IFD1:ThumbnailImage, ExifIFD:DeviceSettingDescription, MPF0:ImageUIDList, etc) are useless in a csv, since there's no actual data there.   You could then list just the tags you need and they will appear in the CSV file in the order listed.

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype


RPRIETO

Quote from: StarGeek on May 18, 2017, 03:09:31 PMSo you'd have to add a check to see if the csv file exists.

Works like a charm.  :)

Thank you again

rui