1

i get this string from a function that reads my .csv file and now i want to convert it to an js array of objects (without the header)...

can anyone help me?

"Name"  "Address"   "Central"   "Unfiltered"    "Description"   "DatapointType" "Security"
"Placeholder1"  "0/0/-" ""  ""  ""  ""  "Auto"
"Placeholder2"  "0/-/-" ""  ""  ""  ""  "Auto"
"Placeholder3"  "0/0/1" ""  ""  ""  "DPT-1" "Auto"
"Placeholder4"  "0/0/2" ""  ""  ""  "DPT-3" "Auto"

i already tried some solutions from here but i think they all dont work cause my csv isnt seperated by "," or ";" (for example)

my csv is seperated by tabs

thanks for your time :)

6
  • So what is it separated by then, are those supposed to be tabs, or what? Commented Aug 11, 2022 at 5:55
  • What is the separator? I see two spaces, sometimes 3 or 4... any rule? Commented Aug 11, 2022 at 5:56
  • its seperated by tabs sry Commented Aug 11, 2022 at 6:03
  • 1
    this is an opinion: don't re-invent the wheel, there are a few great libraries that handle CSV's - of course, it would help if you had a CSV in the first place Commented Aug 11, 2022 at 6:09
  • 1
    To second @JaromandaX's point: there are great libraries out there. The TSV format permits tabs within a field's quotes, and there are probably other rules about special characters. Writing a proper parser is non-trivial. Unless your data is very clean or very simple, it will take less time to find and install a good library than to identify and fix all the problem cases. Commented Aug 11, 2022 at 6:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.