I have a csv file that is read into memory. Using a LINQ query, the fields are parsed and a “where” clause filters down the data. The query is then written out to another csv file.
Dim exampleQuery =
(From line In lines _
Let fields = [login to view URL](",") _
Where ([login to view URL](fields(5)) >= "01/02/1997" And _
[login to view URL](fields(5)) <= "12/02/1999") _
Select From test In fields)
'Just the top result needs to be writen out not every line in the query as shown
For Each test In exampleQuery
[login to view URL](test(0) & "," & test(1) & "," & _
test(2) & "," & test(3) & "," & _
test(4) & "," & test(5) & vbCrLf)
Next
I need the query to be dynamic.
Requirements:
1) The “where” clause needs to be user created and submitted from a multiline text box
2) The “where” clause needs to be customizable by the user
3) The “where” clause should support multiple “and” and “or” statements
4) The user should be able to sort by a field using the “order by” statement – can come from a different textbox
5) Since the number of fields in the csv file are static, the query should map parsed array elements to field names – i.e. “fields(5)” can be referred to as “Date” in the user built query
6) The user should not have to convert types – i.e need to use “[login to view URL]” or any other kind of type conversion for each field. Maybe when the fields are mapped to names they can also be given a type.
Some user submitted example queries:
“NumOfPoints > 20 and LargestBill < 100”
“Order By NumOfPoints DESC”
“NumOfPoints < 10”
“Order By NumOfPoints DESC”
Dim exampleQuery =
(From line In lines _
Let fields = [login to view URL](",") _
Where ([login to view URL](fields(5)) >= "01/02/1997" And _
[login to view URL](fields(5)) <= "12/02/1999") _
Select From test In fields)
// Just the top result writen out not every line in the query
For Each test In exampleQuery
[login to view URL](test(0) & "," & test(1) & "," & _
test(2) & "," & test(3) & "," & _
test(4) & "," & test(5) & vbCrLf)
Next