ExifTool Forum

ExifTool => Newbies => Topic started by: Tr on January 31, 2014, 12:22:20 PM

Title: csv column order ?
Post by: Tr on January 31, 2014, 12:22:20 PM
I am using exiftool to batch edit an image collection by reading/writing .csv file.

Is there a way to define the column order of the output .csv file?

Thanks much in advance.
Title: Re: csv column order ?
Post by: Phil Harvey on January 31, 2014, 12:28:40 PM
Yes.  The CSV colums will be output in the same order that you specify the tags on the command line.  If you are extracting all information (ie. don't specify any tag names), then there is no way to specify the order.

- Phil
Title: Re: csv column order ?
Post by: Tr on January 31, 2014, 04:42:38 PM
I am currently using a long alias in the .ExifTool_config that specifies 59 tags.  Is there anyway to specify the order there?

Thanks again.
Title: Re: csv column order ?
Post by: Phil Harvey on January 31, 2014, 06:46:13 PM
Am I missing something?  Aren't the columns in the same order as the tags in your alias?

- Phil
Title: Re: csv column order ?
Post by: Tr on January 31, 2014, 07:48:15 PM
Below is my shortcut in .ExifTool_config.  The order does not match the csv.

Here is my command line:

>exiftool -AVM -r -csv . > avm.csv -G1 -sep ";" -d " %Y-%m-%d" -a

%Image::ExifTool::UserDefined::Shortcuts = (
    AVM => [
    'DatasetID',
    'Source',
    'CreatorWorkUrl',
    'UsageTerms', 'CopyrightNotice', 'Rights',
    'Title',
    'Caption-Abstract', 'Description',
    'ReferenceURL',
    'Credit',
    'ID',
    'Type',
    'MetadataDate',
    'MetadataVersion' ,
    'Facility',
    'SubjectCategory',
    'Keywords',
    'SpectralBand',
    'Creator',
    'CreatorWorkEmail',
    'CreatorWorkTelephone',
    'CreatorAddress',
    'CreatorCity',
    'CreatorRegion',
    'CreatorPostalCode',
    'CreatorCountry',
    'Headline',
    'Distance',
    'DistanceNotes',
    'DateCreated',
    'ImageProductQuality',
    'PublicationID',
    'ProposalID',
    'Instrument',
    'SpectralColorAssignment',
    'SpectralBandpass',
    'SpectralCentralWavelength',
    'SpectralNotes',
    'TemporalStartTime',
    'TemporalIntegrationTime',
    'SpatialCoordinateFrame',
    'SpatialEquinox',
    'SpatialReferenceValue',
    'SpatialReferenceDimension',
    'SpatialReferencePixel',
    'SpatialScale',
    'SpatialRotation',
    'SpatialCoordsystemProjection',
    'SpatialQuality',
    'SpatialNotes',
    'SpatialFITSheader',
    'Publisher',
    'PublisherID',
    'ResourceID',
    'ResourceURL',
    'SpatialCDMatrix',
    'RelatedResources']
);
Title: Re: csv column order ?
Post by: Phil Harvey on February 01, 2014, 06:06:35 AM
Quote from: Tr on January 31, 2014, 07:48:15 PM
>exiftool -AVM -r -csv . > avm.csv -G1 -sep ";" -d " %Y-%m-%d" -a

This is wrong.  You can't put ExifTool options after a shell redirection (">").  The correct syntax is:

exiftool -AVM -r -csv . -G1 -sep ";" -d " %Y-%m-%d" -a > avm.csv

When I try this, the columns are output in the expected order without the -G1 option.  I'll have to look into this to see why the order changes with -G1.

- Phil
Title: Re: csv column order ?
Post by: Phil Harvey on February 01, 2014, 07:00:15 AM
I will add this note to the exiftool documentation:

        When exporting specific tags, the CSV columns are arranged in the same order
        as the specified tags provided the column headings exactly match the
        specified tag names, otherwise the columns are sorted in alphabetical order.

ExifTool can't preserve the original tag order if the column names are different than the tag names you specified.  So you must specify the family 1 group names in your shortcut if you are extracting with the -G1 option.  This is because any given tag may have different group names, so the fixed column headings won't work.

Dropping the -G1 option is the simplest thing to do if you want to preserve the column order.  The alternative of specifying all of the family 1 group names in your shortcut is a bit tricky.

- Phil
Title: Re: csv column order ?
Post by: Tr on February 03, 2014, 02:52:32 PM
Most awesome.  Dropping -G option.  It was not really necessary anyway. 

Thanks Phil.