package cdr import ( "encoding/csv" ) // Some assumptions on our input, since encoding/csv reads everything as string. We expect 17 entries per line: // cid,time,type,cli,from,to,account,usage,costs,source,destination,leg,reason,package,package_costs,network_costs,service_costs // // - cid is free text, could be argued to be unique, but there are no guarantees. // - time is a timestamp formatted YYYY-MM-DD hh:mm:sd // - type is in {Voice,Data,SMS}, of course the header line is "type" // - cli,from should be \d+ (eg 31676012321) // - to is either [0-9*]+ for a (partially shielded/) phonenumber, or .+ for APN or Voicemail, or the likes // - account is free text (non-empty) // - usage is an integer >= 0 // - costs is a float with four decimal digits. We strip the dot and interpret it as an integer, to avoid weird rounding errors during processing // - source,destination are free text, but typically either empty or take the form "word(s) - word(s) - word(s)" // - leg is an integer >= 1 // - reason is in {ORIG,CFIM,CFOR,CFNA,CFBS,ROAM,PBXOR}, but there might be other ones // - package is free text (or empty) // - {package,network,service}_costs are either empty or conform to the "costs" column // FieldsPerLine are the expected number of fields in each CSV line. const FieldsPerLine = 17 // ImportIndex keeps track of what column corresponds to what data. type ImportIndex int // These are our numbered input fields const ( ImportUnknown ImportIndex = iota ImportCid ImportTime ImportType ImportCLI ImportFrom ImportTo ImportAccount ImportUsage ImportCosts ImportSource ImportDestination ImportLeg ImportReason ImportPackage ImportPackageCosts ImportNetworkCosts ImportServiceCosts )