Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

cgill95
Copy link
Contributor

@cgill95 cgill95 commented May 15, 2020

#454
Implementation of the requested JSON import such that JSON and JSONL can be chosen as import options

Copy link
Member

@Hironsan Hironsan left a 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

Copy link
Member

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

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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):
Copy link
Member

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"]}]

@cgill95
Copy link
Contributor Author

cgill95 commented Jun 17, 2020

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants