hone icon indicating copy to clipboard operation
hone copied to clipboard

Support Appending into Embedded structure

Open Abhisrajput opened this issue 6 years ago • 4 comments

Hi,

Your work is awesome, I was wondering if you can add a support to append inside the embedded structure

For example: In the below data set if first two rows are same then have only one document and embed them into one.

name,age (years),weight (kg),birth day,birth month,birth year,adopted,adopted_since
Tommy,5,3.6,11,April,2011,TRUE,2012
Tommy,5,3.6,12,May,2012,TRUE,2012
Clara,2,8.2,6,May,2015,FALSE,N/A
Catnip,6,3.3,21,August,2011,TRUE,2017
Ciel,3,3.1,18,January,2015,TRUE,2018

Output:

[
    {
        "adopted_since": "2012",
        "weight (kg)": "3.6",
        "birth": [{
            "year": "2011",
            "day": "11",
            "month": "April"
        },{
            "year": "2012",
            "day": "12",
            "month": "April"
        }],
        "age (years)": "5",
        "name": "Tommy",
        "adopted": "TRUE"
    },
    {
        "adopted_since": "N/A",
        "weight (kg)": "8.2",
        "birth": {
            "year": "2015",
            "day": "6",
            "month": "May"
        },
        "age (years)": "2",
        "name": "Clara",
        "adopted": "FALSE"
    },
    {
        "adopted_since": "2017",
        "weight (kg)": "3.3",
        "birth": {
            "year": "2011",
            "day": "21",
            "month": "August"
        },
        "age (years)": "6",
        "name": "Catnip",
        "adopted": "TRUE"
    },
    {
        "adopted_since": "2018",
        "weight (kg)": "3.1",
        "birth": {
            "year": "2015",
            "day": "18",
            "month": "January"
        },
        "age (years)": "3",
        "name": "Ciel",
        "adopted": "TRUE"
    }
]

Abhisrajput avatar Sep 26 '18 12:09 Abhisrajput

Hey, thanks for reaching out! That's an interesting idea, but can I ask what your use case for this would be? This seems like it would have better compression, at the cost of making the schema more complicated.

chamkank avatar Sep 28 '18 19:09 chamkank

Let's say, I am having web portal from where status of few fields changes a couple of time in a day. And at the end of the day I am processing the file and storing in the way I showed you in the above example rather that having a new document. It will definitely save some space.

Just thinking if it's possible.

Thanks

Abhisrajput avatar Oct 01 '18 06:10 Abhisrajput

I agree your work is amazing! Helped me so much.

I do need embedded list/array support also.

Example:

"Resources": [ { "Type": "AwsEc2Instance", "Id": "i-cafebabe", "Partition": "aws", "Region": "us-west-2", "Tags": { "billingCode": "Lotus-1-2-3", "needsPatching": "true" }, "Details": { "AwsEc2Instance": { "Type": "i3.xlarge", "ImageId": "ami-abcd1234", "IpV4Addresses": [ "54.194.252.215", "192.168.1.88" ], "IpV6Addresses": [ "2001:db8:1234:1a2b::123" ], "KeyName": "my_keypair", "VpcId": "vpc-11112222", "SubnetId": "subnet-56f5f633", "LaunchedAt": "2018-05-08T16:46:19.000Z" }
} } ]

rossw7 avatar Dec 18 '18 15:12 rossw7

I need the structure like above, how to mention for the array object[] in the file?

ganeshpitchai avatar Oct 13 '19 10:10 ganeshpitchai