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
#1
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.

unitnumber
idnumber
mail
givenname
manager
department
city
title
mobile

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

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

Any help is appreciated
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  file open "file not found error" shanoger 8 1,086 Dec-14-2023, 08:03 AM
Last Post: shanoger
  Help creating shell scrip for python file marciokoko 10 1,346 Sep-16-2023, 09:46 PM
Last Post: snippsat
  Need to replace a string with a file (HTML file) tester_V 1 760 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  How can I change the uuid name of a file to his original file? MaddoxMB 2 920 Jul-17-2023, 10:15 PM
Last Post: Pedroski55
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,088 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,111 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Creating csv files from Excel file azizrasul 40 5,576 Nov-03-2022, 08:33 PM
Last Post: azizrasul
Photo Making Zip file of a file and Directory Nasir 2 1,015 Oct-07-2022, 02:01 PM
Last Post: Nasir
  Need Help: Convert .pcl file to .pdf file ManuRaval 6 2,539 Sep-13-2022, 01:31 PM
Last Post: ManuRaval
  filter every 24 days file (considering file name) RolanRoll 5 2,209 Jun-23-2022, 11:41 AM
Last Post: RolanRoll

Forum Jump:

User Panel Messages

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