Python Forum
How to convert what appears to be a JSON file to CSV - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to convert what appears to be a JSON file to CSV (/thread-29332.html)



How to convert what appears to be a JSON file to CSV - NewBeie - Aug-28-2020

Hi,
I have this file below, the format looks like it's JSON but I'm not sure, I want to convert it to csv.

I have also attached the file for clear readability.

Quote:(UserResponse){
UserData =
(UserData){
Entry[] =
(UserData){
Active = True
CreatedTime = 2014-07-05 18:38:59.062000+02:00
FirstName = "System"
Lastname = "Account (AddressBook)"
Locked = False
RoleNames =
(RoleNames){
Entry[] =
"Integration admin"
}
UserName = "User1"
UserOrganisation = "Default Organization"
}
(UserData){
Active = True
CreatedTime = 2014-07-05 18:38:59.062000+02:00
FirstName = "System"
LastLoginExt = 2019-04-13 20:04:03+02:00
Lastname = "Account (ChickenFeet)"
Locked = False
RoleNames =
(RoleNames){
Entry[] =
"Integration admin"
}
UserName = "User5"
UserOrganisation = "Default Organization"
}


}
}

please help, how do I convert this file to csv


RE: How to convert what appears to be a JSON file to CSV - Larz60+ - Aug-28-2020

rough pseudo code (2 methods):


RE: How to convert what appears to be a JSON file to CSV - ndc85430 - Aug-28-2020

FWIW, the data you've shown isn't JSON. I don't know what format it is, but perhaps there's a library that parses it. Where did you get it?


RE: How to convert what appears to be a JSON file to CSV - buran - Aug-28-2020

This is not JSON


RE: How to convert what appears to be a JSON file to CSV - Larz60+ - Aug-28-2020

json file usually has suffix .json, not .txt
and must be valid json code which your file is not.