Topic
  • 1 reply
  • Latest Post - ‏2013-03-15T12:14:44Z by SystemAdmin
SystemAdmin
SystemAdmin
603 Posts

Pinned topic Get Count of Fields using JAQL

‏2013-03-12T04:18:15Z |
Hi,

I have a text file as follows,

Id;Name;Designation;Description
101;John;Engineer;Placed at Bangalore
102;Paul;Engineer,Resided at Pune
103;Tin;Cashier;Working at Chennai
104;Lorre;Lawyer;Working at Pune in Infosys
I have filtered "DESIGNATION" using jaql del function as follows

y = del(location="data.txt", delimiter=';', schema= schema { id,Name,Designation,Description});

read(y)
-> filter $.Designation == 'Engineer'
->transform { $.id, $.Family }
->write(seq(location='FINAL', outoptions=txtOutOpt));

It worked fine.

Now the requirement is that If I have a large file say (1gb) and I dont know the column names. But I want to get the count of the column names

Could anyone tell me the syntax to get the count of columns in the given file???

Thanks in advance.
Updated on 2013-03-15T12:14:44Z at 2013-03-15T12:14:44Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    603 Posts

    Re: Get Count of Fields using JAQL

    ‏2013-03-15T12:14:44Z  
    Finally I got the syntax.

    If you have a file consisting of large data (columns and records) , you can get the count of particular column.

    For example, I have a file which has column CITY. Now I can the count of CITY (i.e can get the values count in that particular column) and also get any value from file giving its index.

    x -> group into count($); // gives the count of CITY column

    x -> transform $.CITY -> index(3000); // gives the 3000th position value in CITY column.

    Hope this helps you.