File: import_csv.py

package info (click to toggle)
gaby 2.0.2-6.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,160 kB
  • ctags: 3,248
  • sloc: ansic: 48,660; sh: 8,710; python: 1,161; makefile: 951; perl: 265; sed: 93; xml: 89; sql: 25
file content (22 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /usr/bin/env python
# Created by Frederic Peters; released as GPL
# Needs Python 1.5 !

import sys
import string

try:
	lines = open(sys.argv[1]).readlines()
	f = open(sys.argv[2], 'w')
except:
	print 'Usage: convert inputfile outputfile'
	sys.exit(0)

for i in range(0, len(lines)):
	l = string.split(lines[i][:-1], ',')
	l = map(lambda x: x[1:-1], l)
	l.insert(0, str(i+1))
	f.write(string.join(l, ';') + '\n')

f.close()