cfsimplicity / spreadsheet-cfml

Standalone library for working with spreadsheets and CSV in CFML
MIT License
126 stars 35 forks source link

Trimming column names & values #330

Open Daemach opened 1 year ago

Daemach commented 1 year ago

Discussed in https://github.com/cfsimplicity/spreadsheet-cfml/discussions/329

Originally posted by **Daemach** August 2, 2023 @cfsimplicity I found my first CSV file today that looks like the one below. Can spreadsheet-cfml trim column names and values? I'll have to handle the non numerics, but auto-trimming would be lovely. ``` costBasisPerShare ,purchaseDate,sedol,cusip,isin,ticker,factsetID,shares 109.60 ,1/1/2020,,,,ABBV,,51 110.19 ,1/1/2020,,,,ABT,,37 117.25 ,1/1/2020,,,,AJG,,50 138.07 ,1/1/2020,,,,AMAT,,33 504.55 ,1/1/2020,,,,AVGO,,9 38.12 ,1/1/2020,,,,BAC,,153 59.61 ,1/1/2020,,,,BK,,86 695.75 ,1/1/2020,,,,BLK,,11 63.32 ,1/1/2020,,,,BMY,,95 63.52 ,1/1/2020,,,,C,,57 202.96 ,1/1/2020,,,,CAT,,40 163.56 ,1/1/2020,,,,CCI,,30 41.77 ,1/1/2020,,,,CFG,,67 54.94 ,1/1/2020,,,,CMCSA,,129 50.11 ,1/1/2020,,,,COP,,97 50.87 ,1/1/2020,,,,CSCO,,211 30.88 ,1/1/2020,,,,CSX,,191 - ,1/1/2020,,,,CVX,,90 232.96 ,1/1/2020,,,,DHR,,18 60.71 ,1/1/2020,,,,DOW,,125 ```
bdw429s commented 10 months ago

Possibly related to this bug https://github.com/cfsimplicity/spreadsheet-cfml/issues/339

cfsimplicity commented 10 months ago

@bdw429s I don't think so. The trim option in #339 just removes leading/trailing space from the whole CSV string, whereas this issue is about trimming individual column names/values, which seems to happen anyway (i.e. I haven't been able to replicate it). See the related discussion.

cfsimplicity commented 10 months ago

@Daemach Again could you see if the new readCsv() helps here?

https://github.com/cfsimplicity/spreadsheet-cfml/blob/develop/test/specs/readCsv.cfm