Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I parse the following text file?
    text
    copied!<p>I'm pretty new to c#. Can somebody please give me the right direction on how can I parse the following text file?</p> <p>The program I am trying to implement will do the following:</p> <p>It will ask the user to enter a directory. It will search the directory for text files. It will loop through the text files, parse them, and save them in a one table database. The text files have the following structure:</p> <p>(This is text file 1)</p> <pre><code>001 - Milan (Citizens) Pitch Street John Doe 15, F1 2 35022I Janette Doe 17, F7 2 32345I Angel Street Mark Skate 12, F3 2 35532I Jacqueline Skate 18, F6 2 54343I </code></pre> <p>(This is text file 2)</p> <pre><code>002 - Rome (Citizens) Colosseum Street Christian Troy 21, F8 5 21354I Janette Doe 17, F7 2 23453T Pope Street Sean McNamara Villa McNamara 12424I Julia McNamara Villa McNamara 43344I </code></pre> <p>etc...</p> <p>001 - Milan etc... is the town. This is found once at the beginning of every text file. Colosseum Street etc... is the street name. Then for every street there is a list with 3 columns: name, address, id card.</p> <p>What I need is to insert every citizen into a database. the database will have one table with the following format:</p> <p>name, surname, address, id_card, town, street</p> <p>Therefore, every citizen must be stored in some kind of an array and the array will contain the citizen's respective town and citizen.</p> <p>If somebody can give me some ideas on how to parse the format of this text file it would be great, since it has a bit of an unusual format. Also please note that the spaces between name, address and id card are actual spaces and not tabs.</p> <p>Many thanks in advance!</p> <p>Regards, Chris </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