nickmckay / LiPD-utilities

Input/output and manipulation utilities for LiPD files in Matlab, R and Python
http://nickmckay.github.io/LiPD-utilities/
GNU General Public License v2.0
29 stars 9 forks source link

Python API: CSV name doesn't match filename #24

Closed chrismheiser closed 7 years ago

chrismheiser commented 7 years ago

This error is coming back from lipd.validate(D) on the first try, directly after converting an excel file to LiPD file in python. All subsequent readLipd then validate come back passing

Why?

Because the excel template is using 1-indexed naming for it's data sheets, while the Utilities, and all other code, uses 0-indexed naming.

Example:

Excel Sheets: paleo1measurementTable1 chron1measurementTable1

These sheets generate the filenames: NWG-SL.Lasher.2017.chron1measurement1.csv for the table chron0measurement0 NWG-SL.Lasher.2017.paleo1measurement1.csv for the table paleo0measurement0

Why is it only happening when trying to validate directly after converting an excel file?

Because filenames and table names are not permanent. They are rewritten (to adhere to standard naming) every time you use writeLipd. excel() has a few major steps

  1. convert the excel to and write the LiPD file
  2. readLipd file into memory (the one created in step 1)
  3. writeLipd the LiPD data in memory back the disk (to save all the inferred data and file standardization corrections) The csv filenames in memory from step 2 are mismatched, and this is what goes to the validator. The filenames saved to file, in step 3, are corrected for next time.