Note that there are some explanatory texts on larger screens.

plurals
  1. POPython: Parsing Multiple .txt Files into a Single .csv File?
    text
    copied!<p>I'm not very experienced with complicated large-scale parsing in Python, do you guys have any tips or guides on how to easily parse multiple text files with different formats, and combining them into a single .csv file and ultimately entering them into a database?</p> <p>An example of the text files is as follows:</p> <p>general.txt (Name -- Department (DEPT) Room # [Age]</p> <pre><code>John Doe -- Management (MANG) 205 [Age: 40] Equipment: Laptop, Desktop, Printer, Stapler Experience: Python, Java, HTML Description: Hardworking, awesome Mary Smith -- Public Relations (PR) 605 [Age: 24] Equipment: Mac, PC Experience: Social Skills Description: fun to be around Scott Lee -- Programmer (PG) 403 [Age: 25] Equipment: Personal Computer Experience: HTML, CSS, JS Description: super-hacker Susan Kim -- Programmer (PG) 504 [Age: 21] Equipment: Desktop Experience: Social Skills Descriptions: fun to be around Bob Simon -- Programmer (PG) 101 [Age: 29] Equipment: Pure Brain Power Experience: C++, C, Java Description: never comes out of his room </code></pre> <p>cars.txt (a list of people who own cars by their department/room #)</p> <pre><code>Programmer: PG 403, PG 101 Management: MANG 205 </code></pre> <p>house.txt</p> <pre><code>Programmer: PG 504 </code></pre> <p>The final csv should preferably tabulate to something like: </p> <pre><code>Name | Division | Division Abbrevation | Equipment | Room | Age | Car? | House? | Scott Lee Programming PG PC 403 25 YES NO Mary Smith Public Rel. PR Mac, PC 605 24 NO NO </code></pre> <p>The ultimate goal is to have a database, where searching "PR" would return every row where a person's Department is "PR," etc. There's maybe 30 text files total, each representing one or more columns in a database. Some columns are short paragraphs, which include commas. Around 10,000 rows total. I know Python has built in csv, but I'm not sure where to start, and how to end with just 1 csv. Any help?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload