Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Jq -r 'map {company_number} as $number | .data | (.address | {address_line_1,country,locality,postal_code,premises}) as $address | {ceased_on,country_of_residence} as $details | (.date_of_birth | {month, year}) as $dob | $number + $address + $details + $dob + {etag,kind} | keys_unsorted as $keys | [.[]] as $rows | $keys, $rows | @csv' in.json > out.json jq: error: syntax error, unexpected '{', expecting $end (Unix shell quoting issues?) at <top-level>, line 1: map {company_number} as $number jq: 1 compile error please elaborate Commented Dec 5, 2021 at 8:51
  • Your modification of the jq program is incorrect. It would probably be a good idea if you crafted a more representative but tiny sample of your data, as per the minimal reproducible example guidelines. Commented Dec 5, 2021 at 9:36
  • I have edited/reworded my question and edited the data source : download.companieshouse.gov.uk/en_pscdata.html Commented Dec 5, 2021 at 10:04
  • Aha! It's a stream. A sample of two would probably have sufficed. I tested the revised script against psc-snapshot-2021-12-05_1of20.zip It took about 20 secs. Commented Dec 5, 2021 at 10:35
  • Jq -r -n input in.json prints a data sample, could you elaborate on how to put the different pieces of your answer/snippets together and actually run the code? i have the data in my input file in.json and my script is called script.jq (or script.sh also seem so be accepted) however, im getting errors. /Users/doss/Desktop/ds/test.jq: line 2: input: command not found /Users/doss/Desktop/ds/test.jq: line 2: get: command not found /Users/doss/Desktop/ds/test.jq: line 3: syntax error near unexpected token |' /Users/doss/Desktop/ds/test.jq: line 3: | keys_unsorted as $keys' Commented Dec 5, 2021 at 11:47