Hi Guys,
I’m working with csv files that record 3 attributes of a frequency analysis task. The attributes are time, frequency Hz and confidence (confidence is the level of certainty from 0.0-1.0 that the frequency estimation is accurate).
I have a piece of code here that reads the CSV, storing the values of every row of each column (time=x, frequency=y and confidence=z.) into the variable csvData.
set my_data to read recCsv
set csvData to paragraphs 2 thru -2 of my_data as list -- paragraph 1 is just the attribute names
set freqData to {}
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
repeat with a_reading in csvData
try
set x to text item 1 of a_reading -- timestamp from CSV
set y to text item 2 of a_reading -- frequency readings from CSV
set z to text item 3 of a_reading -- confidence readings from CSV
set end of freqData to y
end try
end repeat
set A to 0
repeat with this_freq in freqData
set A to A + this_freq
end repeat ...
And a short snippet of the CSV readings:
time,frequency,confidence
0.740,46.899,0.401016
0.750,45.635,0.103832
0.760,45.540,0.097100
0.770,45.353,0.071827
0.780,47.367,0.065402
0.790,51.383,0.105370
0.800,55.067,0.160389
0.810,57.213,0.331173
0.820,57.078,0.527134
0.830,56.089,0.696078
0.840,55.007,0.667735
0.850,53.657,0.622470
0.860,52.439,0.739081
I would like to know how to adapt the code so that any row that has a confidence reading lower than 0.6 is disregarded and no information from that row be stored in the variable csvData (if thats possible). I’ve been searching online for info but haven’t found anything thats helped.
Any help would be much aopreciated.
Doug
Model: 2019 2.9 or something xeon core 16gb
AppleScript: Script Debugger 8
Browser: Safari 605.1.15
Operating System: macOS 10.15