Author Topic: csv column order ?  (Read 6061 times)

Tr

  • Jr. Member
  • **
  • Posts: 29
csv column order ?
« 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: csv column order ?
« Reply #1 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

  • Jr. Member
  • **
  • Posts: 29
Re: csv column order ?
« Reply #2 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: csv column order ?
« Reply #3 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

  • Jr. Member
  • **
  • Posts: 29
Re: csv column order ?
« Reply #4 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']
);

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: csv column order ?
« Reply #5 on: February 01, 2014, 06:06:35 AM »
>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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16879
    • ExifTool Home Page
Re: csv column order ?
« Reply #6 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

  • Jr. Member
  • **
  • Posts: 29
Re: csv column order ?
« Reply #7 on: February 03, 2014, 02:52:32 PM »
Most awesome.  Dropping -G option.  It was not really necessary anyway. 

Thanks Phil.