Python Forum
[split] How to convert the CSV text file into a txt file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] How to convert the CSV text file into a txt file
#1
Hello there.
Does anyone know how to convert the CSV text file into a txt file? Because I have 2000++ instances(number of rows) in my dataset so I wanna convert the text from each instance(rows) into 1 txt file, is it possible to do in a short time?

I was searching here and there but couldn't get how. Please do let me know if anyone knows about the problem I am facing.Advance Thank you
Reply
#2
(Dec-23-2020, 06:32 AM)Pinto94 Wrote: Hello there.
Does anyone know how to convert the CSV text file into a txt file? Because I have 2000++ instances(number of rows) in my dataset so I wanna convert the text from each instance(rows) into 1 txt file

You're going to need to explain in more detail what you have and what you're trying to do. CSV is text, so what exactly do you want to do? If you have the data in memory, can't you just write it to a file? If you're using Pandas, there are likely facilities to write data frames to CSV files. Show the code you have and what you've tried.
Reply
#3
(Dec-23-2020, 06:41 AM)ndc85430 Wrote:
(Dec-23-2020, 06:32 AM)Pinto94 Wrote: Hello there.
Does anyone know how to convert the CSV text file into a txt file? Because I have 2000++ instances(number of rows) in my dataset so I wanna convert the text from each instance(rows) into 1 txt file

You're going to need to explain in more detail what you have and what you're trying to do. CSV is text, so what exactly do you want to do? If you have the data in memory, can't you just write it to a file? If you're using Pandas, there are likely facilities to write data frames to CSV files. Show the code you have and what you've tried.



I have a CSV file with texts in each row and I would like to convert the texts from each row to a txt file. Since the number of rows are a lot, hence it would be difficult to convert them manually. Just wondering if there is a way that I can do this using python.
Reply
#4
Do you want a file for each row? Otherwise I don't understand what you mean, because again, CSV is already text.
Reply
#5
(Dec-23-2020, 07:52 AM)ndc85430 Wrote: Do you want a file for each row? Otherwise I don't understand what you mean, because again, CSV is already text.


Yes, I want a txt file for each row.
Reply
#6
Why write a Python script to do this when there are already good tools? If you're on Unix (Linux or Mac, for example), then split should help here. On Windows, there may be something similar (or at least there's Cygwin, which will give you the Unix tools).

You really don't need to keep quoting posts in their entirety - it just wastes space.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  read a text file, find all integers, append to list oldtrafford 7 189 2 hours ago
Last Post: oldtrafford
  How to write in text file - indented block Joni_Engr 4 2,045 Jul-18-2022, 09:09 AM
Last Post: Hathemand
  find some word in text list file and a bit change to them RolanRoll 3 310 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  select files such as text file RolanRoll 2 261 Jun-25-2022, 08:07 PM
Last Post: RolanRoll
  filter every 24 days file (considering file name) RolanRoll 5 797 Jun-23-2022, 11:41 AM
Last Post: RolanRoll
  Sending Whatsapp Message in the text file ebincharles869 9 429 Jun-21-2022, 04:26 PM
Last Post: snippsat
  Modify values in XML file by data from text file (without parsing) Paqqno 2 449 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Extracting Specific Lines from text file based on content. jokerfmj 8 834 Mar-28-2022, 03:38 PM
Last Post: snippsat
  How to split file by same values from column from imported CSV file? Paqqno 5 729 Mar-24-2022, 05:25 PM
Last Post: Paqqno
  Find and delete above a certain line in text file cubangt 12 1,134 Mar-18-2022, 07:49 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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