We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e12c4c commit 1d11e4eCopy full SHA for 1d11e4e
loklak.py
@@ -9,6 +9,7 @@
9
import requests
10
from xmljson import badgerfish as bf
11
from json import dumps
12
+import csv
13
14
15
class Loklak(object):
@@ -63,9 +64,13 @@ def xmlToJson(self, xmlData = None):
63
64
jsonData = dumps(bf.data(fromstring(xmlData)))
65
return jsonData
66
- def csvToJson(self):
67
+ def csvToJson(self, csvData = None, fieldnamesList = None):
68
"""Converts CSV to JSON as the service"""
-
69
+ jsonData = ''
70
+ if csvData:
71
+ data = csv.DictReader( csvData, fieldnames = fieldnamesList)
72
+ jsonData = json.dumps( [ row for row in data ] )
73
+ return out
74
75
def hello(self):
76
"""Gives a hello"""
0 commit comments