Help with data
in
Programming Questions
•
8 months ago
Hello,
Working with
this document file and
this 'frequency' in a week file[time.tsv] (converted to tsv) for Visualization
on an map of India.What would be the best way i should approach this particular case. Wanted to know if i am thinking in the right direction or not. Also, how can i
'cast' data to each other?
Till now, what i have done:
1. Main tab is basically reading the tsv files. Something like -
- Flights[] data;
- Time[] time;
- void setup() {
- map = loadImage("map2.jpg");
- ....
- ........
- schedule = new Table("Indigo Flights.tsv"); ///usual "Table" class (ben fry)
- schedule2 = new Table("Time.tsv");
- // rowCount = schedule.getRowCount();
- data = new Flights[schedule.getRowCount()-1]; //t = schedule
- //println(data);
- String[] lines = loadStrings("Indigo Flights.tsv");
- println("data length is: " + data.length);
- for(int i = 0; i < data.length; i++) {
- String[] pieces = split(lines[i], TAB);
- data[i] = new Flights(i, pieces[0], pieces[1], pieces[2], pieces[3], pieces[4]);
- }
- ......
- time = new Time[schedule2.getRowCount()-1];
- String[] timelines = loadStrings("Time.tsv");
- for(int i = 0; i < time.length; i++) {
- String[] pieces1 = split(timelines[i], TAB);
- time[i] = new Time(i, pieces1[0], pieces1[1], pieces1[2], pieces1[3], pieces1[4], pieces1[5], pieces1[6], pieces1[7], pieces1[8]);
- }
- } ///// end of setup()///////
Next i have is the class Flights-
- class Flights {
- Flights(int i, String FlightNumber, String Origin, String Destination, String DepartureTime, String ArrivalTime) {
- this.Count = i;
- this.FlightNumber = FlightNumber;
- this.Origin = Origin;
- this.Destination = Destination;
- this.DepartureTime = DepartureTime;
- this.ArrivalTime = ArrivalTime;
- Count = i+1;
- FlightNumber = schedule.getString(i+1, 0);
- Origin = schedule.getString(i+1, 1);
- Destination = schedule.getString(i+1, 2);
- DepartureTime = schedule.getString(i+1, 3);
- ArrivalTime = schedule.getString(i+1, 4);
- }
- void getFlightNumber() {
- println("Count is " + Count + "and " + FlightNumber);
- }
- void getOrigin() {
- int l = 10;
- textAlign(LEFT);
- println(Origin);
- }
And the class time from the second link-
- class Time {
- Time(int j, String FlightNumber, String Frequency, String Monday, String Tuesday, String Wednesday, String Thursday, String Friday, String Saturday, String Sunday){
- FlightNumber = schedule2.getString(j+1, 0);
- Frequency = schedule2.getString(j+1, 1);
- Monday = schedule2.getString(j+1, 2);
- Tuesday = schedule2.getString(j+1, 3);
- Wednesday = schedule2.getString(j+1, 4);
- Thursday = schedule2.getString(j+1, 5);
- Friday = schedule2.getString(j+1, 6);
- Saturday = schedule2.getString(j+1, 7);
- Sunday = schedule2.getString(j+1, 8);
- }.....
- etc
- P.s. I also need to store location points on the map. Probably make a 2D array? [xpos][ypos]?
1