0

This is a small part of the CSV :-

"LEADIN","Y","0.003","0.002","3","4.27","584.99","699.59","1162.36","1587.05","4.31","1","80","Small Rutting","Small Rutting","17.8","53.71785592","-2.56060898","173.1","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","1" "LEADIN","Y","0.008","0.007","1.42","4.41","413.34","1237.43","306.49","2743.2","4.44","1","90","Small Rutting","Small Rutting","21.7","53.71789703","-2.56059787","172.9","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","6" "LEADIN","Y","0.013","0.012","2.02","2.6","654.11","611.97","693.14","883.1","2.77","1","70","Small Rutting","Small Rutting","25.3","53.71794075","-2.56058166","172.7","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","11" "LEADIN","Y","0.018","0.017","1.26","6.34","478.49","1054.13","337.17","3550.75","6.34","1","100","Small Rutting","Large Radius","29.8","53.7179844","-2.56056205","172.5","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","16" "LEADIN","Y","0.023","0.022","5.72","2.6","682.96","1180.03","1959.48","1558.87","5.72","2","100","Short Radius - Single Rut","Small Rutting","34","53.71802785","-2.56053799","172.3","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","21" "LEADIN","Y","0.028","0.027","2.76","2.29","734.58","959.17","1120.54","1196.8","2.95","2","60","Small Rutting","Small Rutting","37.8","53.71807003","-2.56050743","172.2","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","26" "LEADIN","Y","0.033","0.032","1.88","2.7","758.48","738.18","812.85","1119.24","2.79","1","90","Small Rutting","Small Rutting","39.8","53.71811095","-2.56047369","171.9","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","31" "LEADIN","Y","0.038","0.037","2.85","4.13","1124.35","1150.24","1531.35","2762.81","4.21","1","90","Small Rutting","Small Rutting","40.3","53.71815122","-2.56043949","171.7","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","36" "LEADIN","Y","0.043","0.042","9.58","3.92","1861.02","1210.96","10202.89","2443.48","9.58","2","100","Large Radius","Small Rutting","41.4","53.71819101","-2.56040444","171.4","FALSE","","04/11/2021","09:43:27","MFV_01","PG68BCU","HG","Y","41"

I want column number 16 &17 in array form.

Guts
  • 11
  • 1
  • Could you share the expected outcome and what you have tried? – axtcknj Mar 16 '22 at 12:10
  • Could you please add bit more details? do you first need to upload the CSV file in javascript code then process the content ? – AntiqTech Mar 16 '22 at 12:14
  • I have the csv file, I just have to read it and I need to access the 16th and 17th column of it. – Guts Mar 16 '22 at 12:16
  • I tried converting the csv file to JSON then to array but when I convert it to JSON it's giving me error :- # Fatal error in , line 0 # Check failed: has_pending_exception(). # # # #FailureMessage Object: 0x7ffcc37b4920 1: 0xb9b7e1 [node] 2: 0x1d2e954 V8_Fatal(char const*, ...) [node] 3: 0xe61351 v8::internal::Isolate::UnwindAndFindHandler() [node] 4: 0x122e06c v8::internal::Runtime_UnwindAndFindExceptionHandler(int, unsigned long*, v8::internal::Isolate*) [node] 5: 0x163271b [node] Trace/breakpoint trap (core dumped) – Guts Mar 16 '22 at 12:19
  • check this out : https://stackoverflow.com/questions/26416304/reading-csv-file-in-to-an-array-using-javascript – AntiqTech Mar 16 '22 at 12:20

1 Answers1

0

By doing a quick google search, I found some examples of CSVtoarray function, like here : https://www.30secondsofcode.org/js/s/csv-to-array

const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
  data
    .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
    .split('\n')
    .map(v => v.split(delimiter));

I think you can easily adapt it to solve your request.

Poco
  • 9
  • 3