File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 22
22
23
23
import os
24
24
import fstimer .printer
25
+ import io , csv
26
+
27
+ def csv2string (data ):
28
+ si = io .StringIO ()
29
+ cw = csv .writer (si )
30
+ cw .writerow (data )
31
+ return si .getvalue ().strip ('\r \n ' )
25
32
26
33
class CSVPrinter (fstimer .printer .Printer ):
27
34
'''Printer class for csv files for single lap races'''
@@ -43,7 +50,7 @@ def file_extension(self):
43
50
44
51
def scratch_table_header (self ):
45
52
'''Returns the header of the printout for scratch results'''
46
- return 'Place,' + ',' . join (self .fields ) + '\n '
53
+ return 'Place,' + csv2string (self .fields ) + '\n '
47
54
48
55
def cat_table_header (self , category ):
49
56
'''Returns the header of the printout for results by category.
@@ -54,7 +61,7 @@ def cat_table_header(self, category):
54
61
def common_entry (self , row ):
55
62
'''Returns the common part of the printout of the entry
56
63
of a given runner for scratch or by category results'''
57
- return ',' . join (row ) + '\n '
64
+ return csv2string (row ) + '\n '
58
65
59
66
def scratch_entry (self , row ):
60
67
'''Returns the printout of the entry of a given runner
Original file line number Diff line number Diff line change 22
22
23
23
import fstimer .printcsv
24
24
import os
25
+ import io , csv
26
+
27
+ def csv2string (data ):
28
+ si = io .StringIO ()
29
+ cw = csv .writer (si )
30
+ cw .writerow (data )
31
+ return si .getvalue ().strip ('\r \n ' )
25
32
26
33
class CSVPrinterLaps (fstimer .printcsv .CSVPrinter ):
27
34
'''Printer class for csv files for multi lap races'''
@@ -43,11 +50,11 @@ def common_entry(self, row):
43
50
idx_lap = self .fields .index ('Lap Times' )
44
51
lap_times = row [idx_lap ]
45
52
row_print [idx_lap ] = lap_times [0 ]
46
- entry = ',' . join (row_print )+ '\n '
53
+ entry = csv2string (row_print )+ '\n '
47
54
if 'Lap Times' in self .fields :
48
55
for i in range (1 , len (lap_times )):
49
56
entry += ',' # for Place
50
57
row_print = ['' for j in range (len (row ))]
51
58
row_print [idx_lap ] = str (lap_times [i ])
52
- entry += ',' . join (row_print ) + '\n '
53
- return entry
59
+ entry += csv2string (row_print ) + '\n '
60
+ return entry
You can’t perform that action at this time.
0 commit comments