Products
  
  
  Crash Magic Online
  
  Intersection Magic
  
  Map Magic
  
  Knowledge Base
  
  
  
  Contact Us
  
  Meeting
  
  Shop
  
  Login
  

 

Knowledge Base Article:IMW212 


Registration keys moved to client area: Select login on the left menu bar.

Knowldegebase:
Search home page  

Sorting an Import file for Intersection Magic

Article created: Jun 16 2009, updated: Dec 12 2012

Background:  Some users may need to sort the files that are being imported. This article was created to show how to sort a file.

Status:  Info - "how to" article
Keywords:  sort,import
Categories:   *Importing* *Data* *Article - references*

Explanation:

Intersection Magic has the ability to import files that use several record lines to record a single crash. Intersection Magic requires multi-line files be grouped contiguously (one following the next) and in the correct order. An import file with one vehicle record per line would need to be grouped by cased id, and ordered by vehicle record. Without the lines of a crash record being grouped together Intersection Magic would treat each records as changes to the original crash record line that was imported, and without the correct order Intersection Magic would import based only on the order of each record in the file.



Solution:

Windows allows files to be sorted with a dos sort command. The sort command can group lines of a text file together. To use the sort command open a dos command window and enter the sort command to sort your file.

sort (file to be sorted) /o (name of the sorted file)  /+ (number of characters on each line to begin the comparison)

Example

In the following examples we will use a file named test.txt in the c:\temp directory. Test.txt file will contain the following lines:

CaseId03,Person01,Vehicle_c
CaseId02,Person01,Vehicle_b
CaseId02,Person02,Vehicle_a
CaseId01,Person01,Vehicle_v

 

A command of:  sort c:/temp/Test.txt /o c:/temp/results01.txt   

will create a results01.txt file with the following lines:

CaseId01,Person01,Vehicle_v
CaseId02,Person01,Vehicle_b
CaseId02,Person02,Vehicle_a
CaseId03,Person01,Vehicle_c

A command of:  sort c:/temp/Test.txt /o c:/temp/results02.txt /+18  

will create a results02.txt file with the following lines:

CaseId02,Person02,Vehicle_a
CaseId02,Person01,Vehicle_b
CaseId03,Person01,Vehicle_c
CaseId01,Person01,Vehicle_v

In this example the sort command ignored the first 18 characters on each line during the sort.

Depending on your import file two sort operations may be required. One sort to group the crash records together, and an additional sort to order the vehicle records.

 

 

 


July 21, 2018 9:42AM

© 1999-2018 Pd' Programming, Inc - Lafayette, CO USA