Page MenuHomeDevCentral

WIP: convert CSV to JSON
AbandonedPublic

Authored by spI33n on Apr 14 2015, 17:57.
Tags
None
Referenced Files
F3908973: D11.diff
Wed, Dec 18, 17:42
Unknown Object (File)
Tue, Dec 17, 08:26
Unknown Object (File)
Sat, Dec 14, 20:44
Unknown Object (File)
Sat, Dec 14, 20:43
Unknown Object (File)
Sat, Dec 14, 20:41
Unknown Object (File)
Sat, Dec 14, 20:35
Unknown Object (File)
Sat, Dec 14, 20:32
Unknown Object (File)
Sat, Dec 14, 20:29
Subscribers

Details

Diff Detail

Repository
rTASACORAEXP Tasacora experimental code
Lint
No Lint Coverage
Unit
No Test Coverage
Branch
feature/csv2json

Event Timeline

spI33n retitled this revision from to WIP: convert csv to json.
spI33n updated this object.
spI33n edited the test plan for this revision. (Show Details)
spI33n added a reviewer: dereckson.
dereckson retitled this revision from WIP: convert csv to json to WIP: convert CSV to JSON.Nov 9 2015, 23:32

Code mainly works.

src/testConvertCsvToJson.py
7

File is currently called testConvertCsvToJson.py, not test.py.

19

some camelCase would be nice here: rowNum, colNum, inputFile

37

extraneous white line

50

a blank line between usage block and main block would be nice (an idea = a paragraph)

dereckson requested changes to this revision.Nov 9 2015, 23:40
dereckson edited edge metadata.
This revision now requires changes to proceed.Nov 9 2015, 23:40
xcombelle requested changes to this revision.Nov 30 2015, 22:10
xcombelle added a reviewer: xcombelle.
xcombelle added a subscriber: xcombelle.

Some python idioms.

src/testConvertCsvToJson.py
13
  • the parameter should be named file_name, the input_file woould be reserved to the real file-
  • instead of doing

    inputfile = open(input_file, "r")

better use

with open(file_name, "r") as input_file:
     #use input_file inside the block
 #here the file is magically closed

It's named context manager and it's good and modern way to open file see http://eigenhombre.com/2013/04/20/introduction-to-context-managers/ for explanations

19
  • actually the standard of python is snake_case, so: row_num, col_num, input_file.
  • instead of counting the rows using the following pattern:

    headers = next(reader) for row in reader: #do what you want with the data row
31

this function don't look really necessary. json.dumps() should be inlined where it is called

41
  • better use os.path.basename()
  • use output_file (snake_case)
  • use the with idiom
45

Abandonning changes with no activity during a long period.

@spI33n if you wish to resume this, you can restore the revision and check Xavier comment. We'll be happy to help.