initial checkin from subversion
This commit is contained in:
30
server/createDataCsv.sh
Normal file
30
server/createDataCsv.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Assumes all JSON files have the same structure.
|
||||
# TODO: Current akw splitting doesn'properly handle double quotes in data resulting in data truncation.
|
||||
|
||||
OutFile="output.csv"
|
||||
|
||||
rm "$OutFile"
|
||||
|
||||
filename=$(ls *.JSON | head -n1)
|
||||
|
||||
grep ":" "$filename" | awk -F "\"" '{ print $2; }' | while read field
|
||||
do
|
||||
echo -e -n "\"${field/\\\"/\"\"}\""";" >> "$OutFile"
|
||||
done
|
||||
echo >> "$OutFile"
|
||||
|
||||
|
||||
ls *.JSON | while read filename
|
||||
do echo processing $filename
|
||||
|
||||
grep ":" "$filename" | awk -F "\"" '{ print $2; }' | while read field
|
||||
do
|
||||
fieldData=$(grep "\"$field\":" "$filename" | awk -F '"' '{ print $4; }')
|
||||
|
||||
echo -e -n "\"${fieldData/\\\"/\"\"}\""";" >> "$OutFile"
|
||||
done
|
||||
echo >> "$OutFile"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user