CSV to Json

Welcome Forums General PowerShell Q&A CSV to Json

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
1 year, 6 months ago.

  • Author
    Posts
  • #69333

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

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

    • #69340

      Participant
      Points: 0
      Rank: Member

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

  • #69343

    Participant
    Points: 0
    Rank: Member

    Can you show your csv file?

  • #69346

    Participant
    Points: 0
    Rank: Member

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

The topic ‘CSV to Json’ is closed to new replies.