spreadsheet-cfml icon indicating copy to clipboard operation
spreadsheet-cfml copied to clipboard

Trimming column names & values

Open Daemach opened this issue 2 years ago • 3 comments
trafficstars

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

Daemach avatar Aug 02 '23 22:08 Daemach

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

bdw429s avatar Nov 03 '23 19:11 bdw429s

@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 avatar Nov 04 '23 11:11 cfsimplicity

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

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

cfsimplicity avatar Nov 07 '23 16:11 cfsimplicity