Python Forum
Creating csv file from another file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating csv file from another file
I have a file that is exported from an upstream system and data is not the same in each row.

But the main attributes in the file are below. Not all the rows might have all the attributes.


Contents in the file are as below and can only have the above attributes.

Quote:('uid=test.test51,ou=People,,o=xerox', {'city': ['Irving'], 'title': ['Application Developer'], 'mobile': ['2054444444'], 'manager': ['test.test100'], 'idnumber': ['44451'], 'department': ['National Claims'], 'mail': [''], 'givenname': ['Test1'], 'unitnumber': ['551']})
('uid=pinuser,ou=People,,o=xerox', {'givenname': ['Pin']})
('uid=jim.gober,ou=People,,o=xerox', {'city': ['Birmingham'], 'title': ['CEO'], 'manager': ['jim.gober'], 'idnumber': ['137741'], 'department': ['Executive'], 'givenname': ['James'], 'unitnumber': ['887']})
('uid=ServiceAdmin,ou=People,,o=xerox', {})
('uid=joann.kerr,ou=People,,o=xerox', {'city': ['Alpharetta'], 'title': ['Senior Software Architect'], 'manager': ['Cynthia Berger'], 'idnumber': ['0003677'], 'department': ['Information Technology'], 'givenname': ['Joann'], 'unitnumber': ['SHD']})

I need to create a csv file from this that has the data in the below format

required o/p:

1st line with header that can be static followed by the data from the above file.
551,44451,,Test1,test.test100,National Claims,Irving,Application Developer,2054444444
SHD,0003677,,Joann,Cynthia Berger,Information Technology,Alpharetta,Senior Software Architect,

Any help is appreciated

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there anyway to make a .py file into a .exe file? Oshadha 2 119 Jan-13-2021, 04:58 AM
Last Post: Oshadha
  [split] How to convert the CSV text file into a txt file Pinto94 5 155 Dec-23-2020, 08:04 AM
Last Post: ndc85430
  xml file creation from an XML file template and data from an excel file naji_python 1 119 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  how to automate sending bulk emails from an excel file or a calc-file apollo 0 162 Dec-10-2020, 08:43 PM
Last Post: apollo
  how to change the range of read CSV file every time python file runs greenpine 6 228 Dec-08-2020, 10:11 PM
Last Post: greenpine
  Saving text file with a click: valueerror i/o operation on closed file vizier87 5 424 Nov-16-2020, 07:56 AM
Last Post: Gribouillis
  Convert file of hex strings to binary file medatib531 4 430 Oct-09-2020, 05:42 PM
Last Post: DeaD_EyE
  saving data from text file to CSV file in python having delimiter as space K11 1 300 Sep-11-2020, 06:28 AM
Last Post: bowlofred
  Trouble with reading csv file and putting it into a file Milfredo 3 378 Sep-04-2020, 05:30 AM
Last Post: Milfredo
  What is meant by "truncates the file" RE MysticLord 5 496 Sep-01-2020, 08:36 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020