-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimporter.py
More file actions
38 lines (22 loc) · 703 Bytes
/
importer.py
File metadata and controls
38 lines (22 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys,os
# Replace with the path to your project
sys.path.extend(['/Users/manuel/Development/prueba/'])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from mysite.models import Phrase
import csv
# Full path to phrase file
file = "lynxoft-test.tab"
reader = csv.reader(open(file), delimiter=',', quotechar='"')
for line in reader:
# Skip header row
if line[0] != 'title':
p = Phrase()
if line[0] is not None:
p.title = line[0]
if line[1] is not None:
p.month = line[1]
if line[2] is not None:
p.day = line[2]
if line[3] is not None:
p.body = line[3]
p.save()