Note that there are some explanatory texts on larger screens.

plurals
  1. POtrying to create a dictionary from a text file
    primarykey
    data
    text
    <p>fieldict(filename) reads a file in DOT format and returns a dictionary with the DOT CMPLID, converted to an integer, as the key, and a tuple as the corresponding value for that key. The format of the tuple is: (manufacturer, date, crash, city, state)</p> <pre><code>fieldict("DOT500.txt")[416] ('DAIMLERCHRYSLER CORPORATION', datetime.date(1995, 1, 9), False, 'ARCADIA', </code></pre> <p>so far, I have tried </p> <pre><code>from collections import defaultdict import datetime def fieldict(filename): with open(filename) as f: x=[line.split('\t')[0].strip() for line in f] #list of complaint numbers y= line.split('\t') #list of full complaints d={} for j in x: Y= True N= False d[j] = tuple(y[2],datetime.date(y[7]), y[6], y[12], y[13]) #dict with number of complaint as key and tuple with index as values return d </code></pre> <p>No luck... I think I am close..any help is greatly appreciated</p> <p>EDIT: each complaint is formatted like this </p> <pre><code>'11\t958128\tDAIMLERCHRYSLER CORPORATION\tDODGE\tSHADOW\t1990\tY\t19941117\tN\t0\t0\tENGINE AND ENGINE COOLING:ENGINE\tWILMINGTON \tDE\t1B3XT44KXLN\t19950103\t19950103\t\t1\tENGINE MOTOR MOUNTS FAILED, RESULTING IN ENGINE NOISE. *AK\tEVOQ\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tV\t\r\n' </code></pre> <p>Entry without character marks showing :</p> <pre><code>11 958128 DAIMLERCHRYSLER CORPORATION DODGE SHADOW 1990 Y 19941117 N 0 0 ENGINE AND ENGINE COOLING:ENGINE WILMINGTON DE 1B3XT44KXLN 19950103 19950103 1 ENGINE MOTOR MOUNTS FAILED, RESULTING IN ENGINE NOISE. *AK EVOQ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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