Programming small white one, bosses guidance! Thank you very much! I now have a taxi GPS data, stored in 25 text file, each text file around 2 gb, each row is a snapshot, format is like this: ,30.624806 1, 104.136604, 1201 4/8/3 21:18:46 From left to right in turn is: the taxi number (a total of 1.2 w car), the current longitude, the current dimensions, whether the current passenger (1 for passenger 0 for no load), the current time I want to do is to convert the GPS data into the taxi passenger movement track of the data, a passenger line trajectory, like this: 1201 4/8/3 21:18:46, 30.624806, 104.136604, 30.702500, 104.072532, 30.702510, 104.072560, 30.702534, 104.072572 From left to right in turn are: the trajectory of the taxi number, start time, then from start to finish of GPS location record As a text file by taxi number for sorting, and every taxi all snapshot is not sorted in chronological order, so I want to 1. The first snapshot at the taxi number, multistage sort time two indicators, 2. Think of some way to put in a good order data into trajectory data (this also have no idea) Problem is data volume is too big, my code is completely motionless, trying a number of ways are useless, for bosses to give directions, thank!
# In [1] Import a datetime Now_time=datetime. Datetime. Now (). The strftime (' % Y - % m % d - m - H - % % % S ') Print (" start_time: "+ STR (now_time)) # [In] The file=r F: \ "didi \ 20140803 _train. TXT". The encode (' utf-8). Decode (' utf-8) With the open (file) as f: Dic=[] For the line in f.r eadlines () : The line=line. Strip (' \ n ') Dic. Append (line. The split (", ")) Now_time=datetime. Datetime. Now (). The strftime (' % Y - % m % d - m - H - % % % S ') Print (" time_1: "+ STR (now_time)) # In [2] # to the time and date for split time column For I in range (0, len (dic)) : Dic [I]. Append (dic [I] [4]. The split (" ") [0]) Dic [I]. Append (dic [I] [4]. The split (" ") [1]) Dic [I]. Remove (dic [I] [4]) Now_time=datetime. Datetime. Now (). The strftime (' % Y - % m % d - m - H - % % % S ') Print (" time_2: "+ STR (now_time)) # In [3] # will be divided into time hours, minutes seconds three columns For I in range (0, len (dic)) : Dic [I]. Append (dic [I] [5]. The split (" : ") [0]) Dic [I]. Append (dic [I] [5]. The split (" : ") [1]) Dic [I]. Append (dic [I] [5]. The split (" : ") [2]) Dic [I]. Remove (dic [I] [5]) Now_time=datetime. Datetime. Now (). The strftime (' % Y - % m % d - m - H - % % % S ') Print (" time_3: "+ STR (now_time)) # In [4] # will taxi, hours, minutes, seconds, date in the first five columns and convenient ordering For I in range (0, len (dic)) : Dic [I]=dic [I] [1-0] + dic [I] [8] + dic [I] [8] + dic [I] [1-3] Dic=sorted (dic) Now_time=datetime. Datetime. Now (). The strftime (' % Y - % m % d - m - H - % % % S ') Print (" end_time: "+ STR (now_time))
CodePudding user response:
great god for help
CodePudding user response:
Database established two libraries, and the new library and old library The first library is the old library, to write text file line by line into the From the old library to extract data from a specific vehicle, and out into a new library, and is expected to be 1.2 w table Pray you the contents of a text file is sorted according to time If not, the new library data needs to be in accordance with the time sequence Then extract a car passenger state is 1, the coordinates of is your