Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding metadata / identifier data to a CSV file?

Tags:

Is there a way to add a "tag" (add a unique metadata/identifier) to a CSV file without affecting the contents or ability to read/write the file?

I am using Python, but I don't think the language matters here.

like image 928
mhy Avatar asked Aug 21 '13 16:08

mhy


People also ask

Does a CSV file have metadata?

Many "CSV" files embed metadata, for example in lines before the header row of the CSV document. This specification does not define any formats for embedding metadata within CSV files, aside from the names of columns in the header row.

What is CSVW?

CSV on the Web is a World Wide Web Consortium (W3C) standard for describing parts of tabular data, including cells, rows and columns. By using CSVW, government organisations can: more easily process CSVs into an annotated data model. make CSVs easy to share and collaborate on. make CSVs machine-readable.


2 Answers

Just add comment lines that you can parse later.

#Creator:JohnSmith
#Date:....
#Columns:id,username,...
1,JohnSmith
2, ..
like image 108
gaborsch Avatar answered Sep 23 '22 12:09

gaborsch


This would be compliant with W3C embedded metadata format: http://www.w3.org/TR/tabular-data-model/#embedded-metadata

#publisher,W3C
#updated,2015-10-17T00:00:00Z
#name,sensor,temperature
#datatype,string,float
sensor,temperature
s-1,25.5
like image 36
Sergei Rodionov Avatar answered Sep 25 '22 12:09

Sergei Rodionov