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

fixed #69 & #72 #73

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

fixed #69 & #72 #73

wants to merge 5 commits into from

Conversation

kanelee7512
Copy link

@kanelee7512 kanelee7512 commented Feb 23, 2021

Summary

This PR should fix issue #69 and #72.
It can correctly flatten the data which has a more than 10 items array. (#69)
It can correctly flatten the data which has an array including another array. (#72)

Bug Fixes/New Features

Fixes #69
Fixes #72

How to Verify

Side Effects

Resolves

Fixes #69
Fixes #72

Tests

Case 1.
data = '''
{
"header": "header a",
"orderItems":[
{"itemLineNumber":1, "itemQuantity":468 },
{"itemLineNumber":2, "itemQuantity":414 },
{ "itemLineNumber":3, "itemQuantity":24 },
{ "itemLineNumber":4, "itemQuantity":24 },
{ "itemLineNumber":5, "itemQuantity":36 },
{ "itemLineNumber":6, "itemQuantity":24 },
{ "itemLineNumber":7, "itemQuantity":84 },
{ "itemLineNumber":8, "itemQuantity":60},
{"itemLineNumber":9,"itemQuantity":42 },
{ "itemLineNumber":10, "itemQuantity":84 },
{"itemLineNumber":11, "itemQuantity":12 },
{ "itemLineNumber":12, "itemQuantity":12 }]
}
'''
result:
[{'orderItems.itemQuantity': 468, 'orderItems.itemLineNumber': 1, 'header': 'header a'}, {'orderItems.itemQuantity': 414, 'orderItems.itemLineNumber': 2, 'header': 'header a'}, {'orderItems.itemQuantity': 12, 'orderItems.itemLineNumber': 11, 'header': 'header a'}, {'orderItems.itemQuantity': 12, 'orderItems.itemLineNumber': 12, 'header': 'header a'}, {'orderItems.itemQuantity': 24, 'orderItems.itemLineNumber': 3, 'header': 'header a'}, {'orderItems.itemQuantity': 24, 'orderItems.itemLineNumber': 4, 'header': 'header a'}, {'orderItems.itemQuantity': 36, 'orderItems.itemLineNumber': 5, 'header': 'header a'}, {'orderItems.itemQuantity': 24, 'orderItems.itemLineNumber': 6, 'header': 'header a'}, {'orderItems.itemQuantity': 84, 'orderItems.itemLineNumber': 7, 'header': 'header a'}, {'orderItems.itemQuantity': 60, 'orderItems.itemLineNumber': 8, 'header': 'header a'}, {'orderItems.itemQuantity': 42, 'orderItems.itemLineNumber': 9, 'header': 'header a'}, {'orderItems.itemQuantity': 84, 'orderItems.itemLineNumber': 10, 'header': 'header a'}]

Case 2.
data = '''
{"header": "header a",
"item": [{"itemLineNumber": 1}, {"itemLineNumber": 2}],
"containerInfo":
[{ "containerId":"A",
"containerItems":[{"itemSKU":1}]},
{"containerId":"B",
"containerItems":[{"itemSKU":2}]},
{"containerId":"C",
"containerItems":[{"itemSKU":3}]},
{"containerId":"D",
"containerItems":[{"itemSKU":4}]},
{"containerId":"E",
"containerItems":[{"itemSKU":5}]}]}
'''
result:
[{'item': 1, 'containerInfo.containerId': 'A', 'header': 'header a', 'containerInfo.containerItems': 1}, {'item': 2, 'containerInfo.containerId': 'A', 'header': 'header a', 'containerInfo.containerItems': 1}, {'item': 1, 'containerInfo.containerId': 'B', 'header': 'header a', 'containerInfo.containerItems': 2}, {'item': 2, 'containerInfo.containerId': 'B', 'header': 'header a', 'containerInfo.containerItems': 2}, {'item': 1, 'containerInfo.containerId': 'C', 'header': 'header a', 'containerInfo.containerItems': 3}, {'item': 2, 'containerInfo.containerId': 'C', 'header': 'header a', 'containerInfo.containerItems': 3}, {'item': 1, 'containerInfo.containerId': 'D', 'header': 'header a', 'containerInfo.containerItems': 4}, {'item': 2, 'containerInfo.containerId': 'D', 'header': 'header a', 'containerInfo.containerItems': 4}, {'item': 1, 'containerInfo.containerId': 'E', 'header': 'header a', 'containerInfo.containerItems': 5}, {'item': 2, 'containerInfo.containerId': 'E', 'header': 'header a', 'containerInfo.containerItems': 5}]

Code Reviewer(s)

@amirziai , @amir-ziai-zefr

@pep8speaks
Copy link

pep8speaks commented Feb 23, 2021

Hello @kanelee7512! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 325:80: E501 line too long (81 > 79 characters)

Comment last updated at 2021-02-24 14:11:42 UTC

@amirziai
Copy link
Owner

thanks for the PR @kanelee7512. do you mind adding your examples to the tests? i will reviewer later this week.

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