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
#1
I'm a beginner in programming, but for a Dutch text categorization experiment I want to turn every instance (row) of a csv file into separate .txt files. The texts make up my dataset which has to be analyzed by a NLP tool. The header of my csv looks like this: ID Label Taaloefening1 Taaloefening2

Each instance has text in either the column 'Taaloefening1' or in the column 'Taaloefening2'. Now I need to save the text per instance in a .txt file and the name of the file needs to be the id and the label.
I was hoping I could to this automatically by programming a script in Python by using the csv module. I may have an idea about how to save the text into a .txt file, but I have no idea how to take the id and label, which match the text, as the file name.
Any ideas?
Reply


Messages In This Thread
Data csv file into different text files with Python - by Bambi - Jun-10-2017, 03:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems writing a large text file in python Vilius 4 1,008 Dec-21-2024, 09:20 AM
Last Post: Pedroski55
  To fetch and iterate data from CSV file using python vyom1109 3 1,022 Aug-05-2024, 10:05 AM
Last Post: Pedroski55
  Reading an ASCII text file and parsing data... oradba4u 2 1,436 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,662 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  Replace a text/word in docx file using Python Devan 4 21,585 Oct-17-2023, 06:03 PM
Last Post: Devan
  save values permanently in python (perhaps not in a text file)? flash77 8 2,694 Jul-07-2023, 05:44 PM
Last Post: flash77
  script to calculate data in csv-files ledgreve 0 2,351 May-19-2023, 07:24 AM
Last Post: ledgreve
  azure TTS from text files to mp3s mutantGOD 2 3,142 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,026 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  python run all py files from main py file mg24 6 3,595 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