Python Forum
Data csv file into different text files with Python
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data csv file into different text files with Python
#2
A file name is just a string that you can create by splicing other strings. So assuming you can read the CSV line into id, label and data,

with open(id+'_'+label+'.txt','w') as linefile:
   linefile.write(data)
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
RE: Data csv file into different text files with Python - by Ofnuts - Jun-11-2017, 08:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems writing a large text file in python Vilius 4 988 Dec-21-2024, 09:20 AM
Last Post: Pedroski55
  To fetch and iterate data from CSV file using python vyom1109 3 1,009 Aug-05-2024, 10:05 AM
Last Post: Pedroski55
  Reading an ASCII text file and parsing data... oradba4u 2 1,409 Jun-08-2024, 12:41 AM
Last Post: oradba4u
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 3,595 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  Replace a text/word in docx file using Python Devan 4 21,023 Oct-17-2023, 06:03 PM
Last Post: Devan
  save values permanently in python (perhaps not in a text file)? flash77 8 2,666 Jul-07-2023, 05:44 PM
Last Post: flash77
  script to calculate data in csv-files ledgreve 0 2,313 May-19-2023, 07:24 AM
Last Post: ledgreve
  azure TTS from text files to mp3s mutantGOD 2 3,106 Jan-17-2023, 03:20 AM
Last Post: mutantGOD
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 2,000 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  python run all py files from main py file mg24 6 3,561 Oct-12-2022, 04:41 AM
Last Post: mg24

Forum Jump:

User Panel Messages

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