Hi All, Is there a particular reason why a CSV file generated by the AppSheet has a random arrangement of the rows in the data table? When I refer back to the original Google Sheet, the rows are in correct order, but the CSV file shows data in a haphazard manner. Any reason for this behavior?
Good question I was just wondering that myself.
The action’s Do this actually says: App: export this view to a CSV file I just tested it and as expected if you set a sort order for a table view, the exported CSV file will respect the same sort order.
However if the view has no particular sort order, the generated CSV seems to be in random order. Perhaps in that case it should have been in key column order? @praveen
Or maybe row number?
Okay @RezaRaoofi and@Lynn Thank you very much. I’ll try setting a sort order.
You’re welcome!
@RezaRaoofi Hi, I tried setting up a sort order (well, I actually used the _RowNumber, Ascending as I thought that’s the easiest for my requirement), but still the CSV is generated in a very random order. Would like your help here! Thanks.
@Malaka_Jayawardene
I have not tried sorting by _RowNumber myself; perhaps it has to be a different sort order.
Perhaps sort by _RowNumber is equivalent to “no sort order”.
Hi guys, has one found the solution? I also noticed the same problem with random rows order in exported CSV file.
Row Ordering> > You can control row ordering by specifying Sort by for the View .
By my own testing, you can’t sort by a column that is not included in the view/column order.
You can, of course, but it won’t affect the CSV.
This might be a bug or not expected behaviour.
@Phil Can you give us some insight about this?
In view I use to export there are all columns so it is not the reason I think. As for [_RowNumber], it is hard to say I do not know whether it includes into the CSV… Thanks for help!
I did my testing and the rows are sorted if I’m using a column that is shown in the view
SkrOYC:
Export This View to a CSV File | AppSheet Help Center> > > ### Row Ordering> > > You can control row ordering by specifying Sort by for the View .
Yes it is the solution but only if you sort other columns than [_RowNumber]!
In my case won’t work
Thanks for help again!
SkrOYC:
By my own testing, you can’t sort by a column that is not included in the view/column order.> You can, of course, but it won’t affect the CSV.> This might be a bug or not expected behaviour.> @Phil Can you give us some insight about this?
It would not make sense to sort a DATA file by a column that is NOT included in the data. For any arbitrary user (or process) who wouldn’t know how it was sorted in the first place, it would still be “randomly” sorted.
If you NEED to sort by a column, it should be included. It has value to the consumer, if only to be able to deduce HOW the data was sorted.
mateo:
Yes it is the solution but only if you sort other columns than [_RowNumber]!
You really do not want, nor should you need, to sort by Row Number. That value is given by AppSheet based on order of the rows being loaded and as such is arbitrary.
WillowMobileSystems:
It would not make sense to sort a DATA file by a column that is NOT included in the data.
It does since that’s how you sort a table on the app to show data from high to low or log to high using [_RowNumber] and it should export the table to CSV respecting that order.
We have no obligation to create a hidden NOW() column to each one of our table just to have the same functionality. If that’s the case, we shouldn’t be able to select [_RowNumber] at all.
I like the fact that we can sort the rows on a table view with a column that is not shown / is not in the column order since that prevents the table to show the arrow Up or Down on a column that ends up distracting the user.
SkrOYC:
It does since that’s how you sort a table on the app to show data from high to low or log to high using [_RowNumber] and it should export the table to CSV respecting that order.
I get what you are saying. All I can say is a repeat, using Row Number for sorting has no value but if you do sort the data by that number, it DOES have value to the resulting data and therefore it should be included.
SkrOYC:
If that’s the case, we shouldn’t be able to select
[_RowNumber]at all.
Row Number is a legacy item and kept for that reason. Knowing how its assigned, I personally never use the value.
WillowMobileSystems:
I personally never use the value.
So the NOW() InitialValue hidden and added on every single table is the only way to go?
How do you sort by newest added to the oldest without [_RowNumber]? Just curious
Maybe you don’t do that at all!

