Skip to content

Commit 2ff9523

Browse files
committed
minor edits
1 parent 62eff48 commit 2ff9523

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mysqldump_to_csv/mysql_dump_to_csv.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import sys
55
import re
66

7-
#This will hold the table name as key, and columns as values.
7+
# This will hold the table name as key, and columns as values.
88
mainDict = {}
99

1010

1111
def createStatement(line):
1212
return line.startswith('CREATE TABLE')
1313

14-
#to detect fields, aka column names
14+
# To detect fields, aka column names
1515
def fieldDef(line):
1616
return line.strip().startswith('`')
1717

@@ -31,15 +31,15 @@ def getCleanedValue(line):
3131

3232
def getValueTuple(line):
3333
values = line.partition(' VALUES ')[-1].strip().replace('NULL', "''")
34-
#To exclude the ;
34+
# To exclude the ;
3535
if values[-1] == ';':
3636
values = values[:-1]
3737

3838
return ast.literal_eval(values)
3939

4040

4141
def writeFile(outputDirectory, tableName, schema, values):
42-
#File name that the current table will be assigned to
42+
# File name that the current table will be assigned to
4343
fileName = os.path.join(outputDirectory, '%s.csv' % (tableName,))
4444
with open(fileName, 'w') as writeFile:
4545
writer = csv.DictWriter(writeFile, fieldnames=schema)
@@ -65,5 +65,6 @@ def parseFile(fileName, outputDirectory):
6565
values = getValueTuple(line)
6666
writeFile(outputDirectory, tableName, currentTable, values)
6767

68+
6869
if __name__ == '__main__':
6970
parseFile(sys.argv[1], sys.argv[2])

0 commit comments

Comments
 (0)