ReadStat icon indicating copy to clipboard operation
ReadStat copied to clipboard

CSV export data types

Open basgys opened this issue 4 years ago • 1 comments

Hi @evanmiller,

I would like to improve the CSV conversion. Currently dates are exported as integers, and I am even wondering whether I introduced a regression on my last PR.

Could you point me in the right direction to improve the CSV export?

From what I understand, it is handled by this function: /src/bin/write/mod_csv.c#L101

Do you think we could we could reuse the metadata extraction implemented? /src/bin/extract_metadata.c#L90

I remember you mentioned metadata extraction that should be centralized, because right now we have some bits in ReadStat and bits in extract_metadata.

Let me know how I should approach this problem.

basgys avatar Feb 08 '21 16:02 basgys

Yep that's the place for it. Basically, CSV is generated in a streaming fashion directly from the ReadStat value handler. Since none of the date stuff is cross-format you'll most likely need to check the underlying file format and then see if the provided format looks like a date format (that's what the simplistic EDATE40 check is doing). Likely the metadata extraction functions could be reused but I haven't looked at it closely.

evanmiller avatar Feb 08 '21 19:02 evanmiller