Main Menu

csv column order ?

Started by Tr, January 31, 2014, 12:22:20 PM

Previous topic - Next topic

Tr

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

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

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tr

Most awesome.  Dropping -G option.  It was not really necessary anyway. 

Thanks Phil.