Closed KaminoU closed 4 years ago
Hi @KaminoU ,
In queries without ORDER BY/GROUP BY it is possible to use the following trick:
SELECT * WHERE NR == 1 or re.match('GP001189', a2)
Or something like this if you are doing string transformations:
SELECT int(a3) / 1000 if NR > 1 else a3, *
In more complex cases, I think, the only possible solution would be to use UNION as you suggested, but it is not supported (yet?)
The trick works well thx =)
Btw, is there a more friendly way to select on date ? for a specific year for example SELECT * WHERE NR == 1 OR re.match("\d{2}/\d{2}/2019", a55)
regex could be painful... lol
Ayway thank you for this great trick! ^^
@mechatroner
Sorry to bother you again, is there a way to work directly on an whole row?
We have only columns, designed by a1...a{n} but what if we want to work directly on the whole line?
The main reason I ask it is because I need to know in my input CSV file, if there is any weirds non printable characters or not SELECT count(1) WHERE re.findall('\x0D\x0A', 'full_row')
for example
Thank you again for your reply
@KaminoU
For string parsing you can do something like this:
select * where datetime.datetime.strptime(a55, "%d/%m/%Y").year == 2019
If you are often working with the the dates in the same format you can create a UDF in the ~/.rbql_init_source.py
file:
def get_year(src_str):
return year datetime.datetime.strptime(src_str, "%d/%m/%Y").year
Regarding full_rows, I was sure that it is possible to do this, but turns out it is not, so I will have to fix this. For now you can use standalone rbql package with "monocolumn" policy:
$ pip install rbql
$ rbql-py --input /path/to/input.txt --policy monocolumn --delim ''
wow!!!!!!! =D
Thank you very much!!! ^^
I am eager to see the new fix for the column and union =)
@KaminoU I just published version 1.5.0, now you can run RBQL even for non-table files - just enter "Rainbow CSV: RBQL" command and it should work! Also updated RBQL supports named columns like a.Age
or a.phone_number
.
If you see any problems - please let me know.
Hello @mechatroner
Thank you for this great plugin, I would like to know if there is a possibility to include the header in the new temp tab with sub CSV data, result of the RQBL?
When it only contains few columns, it is still OK, but it's not always easy to read with a lot of rows/columns, without the header... ='(
Thank you in adavance for your reply
Cheers,
I have tried to append 2 RBQL but it does not us allow to do that
SELECT TOP 1 * UNION SELECT * WHERE re.match('GP001189', a2)
The first part will grab the header etc...