Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

load csv with sort

Hi guys,

Could you tell me if possible to load csv file with order by?

Thanks,

1 Solution

Accepted Solutions
Digvijay_Singh

I think order can only be controlled after loading the file into QV, like below or may be other ways but it has to be loaded first so that QV functions can work -

Table1:

LOAD Country,

     Customer,

     Sales

FROM

Data.csv

(txt, utf8, embedded labels, delimiter is ',', msq);

NoConcatenate

Output:

Load * Resident Table1 Order By Sales Desc;

Drop Table Table1;

View solution in original post

9 Replies
Digvijay_Singh

I think order can only be controlled after loading the file into QV, like below or may be other ways but it has to be loaded first so that QV functions can work -

Table1:

LOAD Country,

     Customer,

     Sales

FROM

Data.csv

(txt, utf8, embedded labels, delimiter is ',', msq);

NoConcatenate

Output:

Load * Resident Table1 Order By Sales Desc;

Drop Table Table1;

Anonymous
Not applicable
Author

I did like you suggested.

In 1 table it's not doable

Thanks,

Not applicable
Author

Vladimir,

Not posible, "order by" function is only executable in resident table.

Regards.

Anonymous
Not applicable
Author

Thank you for confirming

Digvijay_Singh

Yup, found few similar questions but don't see any direct option of loading and sorting in one go.

Not applicable
Author

"order by is a clause used for sorting the records of a resident table before they are processed by the load statement. The resident table can be sorted by one or more fields in ascending or descending order. " References Manual 11.2 SR12 - Page 255.

Clever_Anjos
Employee
Employee

You can use a precedent load

Table1:

LOAD Country,

     Customer,

     Sales

Order By Sales Desc;

LOAD Country,

     Customer,

     Sales

FROM

Data.csv

(txt, utf8, embedded labels, delimiter is ',', msq);

Not applicable
Author

Clever,

You are sure? I understand with precedent load only use function "Where, While and Group By"

Regards.

Anonymous
Not applicable
Author

Something is wrong. I need to add autonumber based on my sort.

Capture.PNG

CSV:

LOAD AutoNumber(TimeStamp) as Auto_Id,

  SessionID,

     Url,

     TimeStamp,

     ValidData

ORDER BY SessionId, [TimeStamp] ASC;

LOAD AutoNumber(TimeStamp) as Auto_Id,

     SessionID as SessionId,

     Url,

     TimeStamp,

     ValidData

FROM

(txt, codepage is 1251, embedded labels, delimiter is ',', msq)

where match(SessionID,$(vValue));