CSV to Json

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Powersheller Powersheller 4 weeks, 1 day ago.

  • Author
    Posts
  • #69333
    Profile photo of Powersheller
    Powersheller
    Participant

    Hello,
    i have an excel file with 2 columns and multiple rows in it, i saved it as csv file using excel save as option, i imported that csv file using import-csv and stored it in a variable , when i try to convert that to json using convertto-json, it keeps throwing the error "ConvertTo-Json : The converted JSON string is in bad format."
    But when i convert it with -compress , it works but it looks ugly and not usable for me. Any help? is there a way to construct a json file from csv using the values stored in variable or is there a way to decompress the compressed json file to make it work

  • #69336

    Hi,
    Do you have headers in csv file? Do you specify delimiter when importing csv?

    • #69340
      Profile photo of Powersheller
      Powersheller
      Participant

      yes i have headers and even if i specify delimiters it does not work 🙁

  • #69343

    Can you show your csv file?

  • #69346
    Profile photo of Powersheller
    Powersheller
    Participant

    it has some values in it, if i edit those, excel restarts automatically 😮

You must be logged in to reply to this topic.