Python Forum
Extracting data from multiple txt files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extracting data from multiple txt files
#6
Thank you for the answer, actually it is a bit more complicated than I expected because there are more than 200 persons in the files and there is first and last name and more than one lines for everyone. I need to extract lines to separate file for every person of what he/she says and give to each file the corresponding name.
For example:

One of multiple input txt files
1.Rich Smith: I'm going to attend a concert on Saturday.
Do you have any special plans?
2.Peter Aderson : No, I'm going to relax. What did you do last weekend?
3.Rich Smith: Last weekend, I went to visit my friends in San Francisco. What did you do?
4.Peter Aderson: I played soccer with some friends.
5.Mary Sarah: Hello
6.John Daisa: hi

I need to have for output:
Rich.txt
Rich Smith: I'm going to attend a concert on Saturday
Rich Smith: Last weekend, I went to visit my friends in San Francisco. What did you do?

Peter.txt
Peter Aderson: No, I'm going to relax. What did you do last weekend?
Peter Aderson: I played soccer with some friends.

Mary.txt
Mary Sarah: Hello

John.txt
John Daisa: hi

I am thinking to have another file with the list of names and somehow to check it with the dialogue files but still it is complicated.
I am beginner in python, and this looks impossible to me.
Reply


Messages In This Thread
RE: Extracting data from multiple txt files - by Emmanouil - Aug-24-2019, 09:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to generating multiple json files using python script dzgn989 4 274 May-10-2024, 03:09 PM
Last Post: deanhystad
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 1,202 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  python convert multiple files to multiple lists MCL169 6 1,692 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  splitting file into multiple files by searching for string AlphaInc 2 979 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  script to calculate data in csv-files ledgreve 0 1,166 May-19-2023, 07:24 AM
Last Post: ledgreve
  Merging multiple csv files with same X,Y,Z in each Auz_Pete 3 1,260 Feb-21-2023, 04:21 AM
Last Post: Auz_Pete
  unittest generates multiple files for each of my test case, how do I change to 1 file zsousa 0 1,005 Feb-15-2023, 05:34 PM
Last Post: zsousa
  Find duplicate files in multiple directories Pavel_47 9 3,286 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  Extracting Data into Columns using pdfplumber arvin 17 5,887 Dec-17-2022, 11:59 AM
Last Post: arvin
  SQL Alchemy help to extract sql data into csv files mg24 1 1,874 Sep-30-2022, 04:43 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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