Python Forum

Full Version: How do I make a Django model from a tab-delimited data file?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a tab-delimited data file that looks something like this:

[inline] NAME S1903_C02_001E state county tract State-County-Tract-ID
Census Tract 201, Autauga County, Alabama 66000 01 001 020100 01001020100
Census Tract 202, Autauga County, Alabama 41107 01 001 020200 01001020200
Census Tract 203, Autauga County, Alabama 51250 01 001 020300 01001020300[/inline]

I want to make a Django model named MyModel with three columns: "name", "data", and "geoid", which correspond to the file's columns "NAME", "S1903_C02_001E", and "State-County-Tract-ID." Can I do this via command line, or with a custom Python script? I'm running my Django project locally on a computer running Debian 9.3.