Skip to content

Instantly share code, notes, and snippets.

@M1ke
Last active December 21, 2015 08:58
Show Gist options
  • Save M1ke/6281395 to your computer and use it in GitHub Desktop.
Save M1ke/6281395 to your computer and use it in GitHub Desktop.
Bash script to write column headings for CSVs downloaded via FTP from the Vebra 5.2 property management platform.

For developers working to import properties from the GMG Property Services software platform Vebra 5.2. The files provided are missing field headers which can require extra work from existing CSV parsing libraries which will require a column name input by number, which at the very least is awkward to type out.

This shell script abstracts this task away from your application - simply run this after the FTP download completes and your application can process the files with native CSV libraries without any additional input for interpreting column numbers or input of column titles. The headings are taken from official documentation.

#!/bin/bash
field_titles_clients='"Cl_FirmID","Cl_BranchID","Cl_Name","Cl_Street","Cl_Town","Cl_County","Cl_Postcode","Cl_Phone","Cl_Email"'
field_titles_files='"Prop_VebraID","File_url","File_type","File_index","File_Caption","File_Updated"'
field_titles_properties='"Prop_ID","Prop_FirmID","Prop_BranchID","Prop_Name","Prop_Street","Prop_Town","Prop_County","Prop_DisplayPcode","Prop_Postcode","Prop_Price","Prop_PriceQualifier","Prop_PropType","Prop_Status","Prop_Bedrooms","Prop_Receptions","Prop_Description","Prop_LastUpload","Prop_Bullet1","Prop_Bullet2","Prop_Bullet3","Prop_Bullet4","Prop_Bullet5","Prop_Bullet6","Prop_Bullet7","Prop_Bullet8","Prop_Bed1Imp","Prop_Bed2Imp","Prop_Bed3Imp","Prop_Bed4Imp","Prop_Bed5Imp","Prop_Bed6Imp","Prop_Rec1Imp","Prop_Rec2Imp","Prop_Rec3Imp","Prop_Rec4Imp","Prop_KitchImp","Prop_Bed1Met","Prop_Bed2Met","Prop_Bed3Met","Prop_Bed4Met","Prop_Bed5Met","Prop_Bed6Met","Prop_Rec1Met","Prop_Rec2Met","Prop_Rec3Met","Prop_Rec4Met","Prop_KitchMet","Prop_Locality","Prop_AddrFields","Prop_AgentRef","Prop_PriceIsPcm","Prop_Systemid","Prop_Category","Prop_DisplayPrice","Prop_HasImage","Prop_HasVTour","Prop_VebraID","Prop_EECurrent","Prop_EEPotential","Prop_EICurrent","Prop_EIPotential","Prop_Furnished","Prop_FrenchDepartm","Prop_PropType2","Prop_CommRent","Prop_ImpMinArea","Prop_ImpArea","Prop_MetArea","Prop_MetMinArea","Prop_AgentLocn","Prop_DisplayAddress","Prop_Bathrooms","Prop_deposit","Prop_rmrentaltype","Prop_detailsurl","Prop_vebra360url","Prop_availdate","Prop_bullet9","Prop_bullet10","Prop_user1","Prop_user2"'
field_titles_rooms='|RM_Propid|,|RM_index|,|RM_Name|,|RM_Imperial|,|RM_Metric|,|RM_Description|,|RM_Dimensions|,|RM_Fileref|'
sed -i '1i '$field_titles_files files.txt
sed -i '1i '$field_titles_rooms rooms.txt
sed -i '1i '$field_titles_clients vebraclients.txt
sed -i '1i '$field_titles_properties vebraproperties.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment