Quote:
8. Another alternative would be to set IFS prior to 'read' so that the values are split for you
|
ifs works great for CSV files
-- NOT the same as your issue but an example
recently i hacked this together
Code:
#!/bin/bash
INPUT=aa1.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read name size lat long
do
echo " Location "$name" "Sol/Ceres" "
echo " { "
echo " LongLat [ $long $lat 0 ] "
echo " Size $size "
echo " Type "AA" "
echo " } "
done < $INPUT
IFS=$OLDIFS
reads through the csv line and pasts parte into a new file
to extract a few sections in a csv line and formatting into what would look like a xml file
from this
Code:
"Abellio","Ceres",32,33.2,293.09,"Planetocentric +East 0 - 360","Approved","Dec 4, 2015","Gaul god of the apple tree.",
"Achita","Ceres",40,25.82,65.96,"Planetocentric +East 0 - 360","Approved","Sep 21, 2015","Nigerian god of agriculture.",
to this
Code:
Location "Abellio" "Sol/Ceres"
{
LongLat [ -293.09 33.2 0 ]
Size 32
Type "AA"
}
Location "Achita" "Sol/Ceres"
{
LongLat [ 65.96 25.82 0 ]
Size 40
Type "AA"
}