-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/json import #777
Feature/json import #777
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some test cases.
@@ -390,6 +390,30 @@ def parse(self, file): | |||
if data: | |||
yield data | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
raise FileParseException(line_num=i, line=line) | ||
|
||
if data: | ||
yield data | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line.
app/api/utils.py
Outdated
file = io.TextIOWrapper(file, encoding=file.encoding) | ||
data = [] | ||
for i, line in enumerate(file, start=1): | ||
#Remove trailing new line and comma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space after a hash.
app/api/utils.py
Outdated
for i, line in enumerate(file, start=1): | ||
#Remove trailing new line and comma | ||
line = line.rstrip('\n').rstrip(',') | ||
#Skip first and last line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space after a hash.
app/api/utils.py
Outdated
@@ -390,6 +390,30 @@ def parse(self, file): | |||
if data: | |||
yield data | |||
|
|||
class JSONParser(FileParser): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONParser is not enough to parse JSON file. For example:
[{"text": "Terrible customer service.", "labels": ["negative"]},{"text": "Really great transaction.", "labels": ["positive"]},{"text": "Great price.", "labels": ["\
positive"]}]
ac9ed0e
to
23885bc
Compare
@Hironsan the JSONParser now works with all kind of JSON lines as well as nested structures that include the "meta" keyword. Hopefully this can be merged into the master now. |
51f743d
to
6781366
Compare
#454
Implementation of the requested JSON import such that JSON and JSONL can be chosen as import options