[Solved] Undesired sort order after import of CSV file

Discuss the spreadsheet application
Post Reply
zmix
Posts: 4
Joined: Sun Mar 24, 2024 12:12 am

[Solved] Undesired sort order after import of CSV file

Post by zmix »

I found that I cannot sort by date because the data didn't include leading zeros, so when I do sort by date (M/D/Y) it looks like


1/5/2023
1/25/2023
10/20/2023
10/25/2023
11/12/2023
12/12/2023
3/5/2023
4/6/2023

It's a mess..


Is there a way to correct the lack of leading zeros?
Screen Shot 2024-03-23 at 6.44.06 PM.jpg
Screen Shot 2024-03-23 at 6.44.06 PM.jpg (119.91 KiB) Viewed 794 times
 Edit: Changed subject, was Cannot sort by Date because the data didn't include leading zeros.. help? 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Last edited by MrProgrammer on Thu Mar 28, 2024 5:53 pm, edited 1 time in total.
Open Office 4.1.5 macOS 10.14.6
zmix
Posts: 4
Joined: Sun Mar 24, 2024 12:12 am

General sorting question...

Post by zmix »

I posted here about sorting by date when there wasn't a leading zero on the month, but sorting an amount is just as confusing.

I tried to sort by the amount in the 'net' column, but it's bizarrely inaccurate...
Screen Shot 2024-03-23 at 6.39.12 PM.jpg
Screen Shot 2024-03-23 at 6.39.12 PM.jpg (71.67 KiB) Viewed 796 times
Open Office 4.1.5 macOS 10.14.6
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Cannot sort by Date because the data didn't include leading zeros.. help?

Post by FJCC »

Your dates and your numbers have entered the cells as text and are being sorted alphabetically. How is the data being entered into Calc?
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
zmix
Posts: 4
Joined: Sun Mar 24, 2024 12:12 am

Re: Cannot sort by Date because the data didn't include leading zeros.. help?

Post by zmix »

FJCC wrote: Sun Mar 24, 2024 12:55 am Your dates and your numbers have entered the cells as text and are being sorted alphabetically. How is the data being entered into Calc?
It was a .csv file provided by Paypal that I imported.
Open Office 4.1.5 macOS 10.14.6
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Cannot sort by Date because the data didn't include leading zeros.. help?

Post by robleyd »

I've merged your questions as they are both the same problem; your "dates" are in fact stored as text and so are the "numbers" in your second post. You caa use Ctrl+F8 or View | Value Highlighting to confirm this. Text cells are formatted in black, formulae in green, and number cells in blue, no matter how their display is formatted.

See [Tutorial] Ten concepts that every Calc user should know for more information on types of data in Calc - or any other spreadsheet.

[Tutorial] Text to Columns may help you with a fix. If the data was imported from e.g. a CSV file, make sure in future you check the option Detect Special Numbers.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Cannot sort by Date because the data didn't include leading zeros.. help?

Post by FJCC »

In the Text Import dialog that you should get as part of importing a csv file, there is a table at the bottom showing a few rows of data and the data type under which they will be imported. The default type is Standard. Right click on the word standard and pick something appropriate for the column. Your date column should work with the mdy setting and your numbers should work with US English.
And, as robleyd said, click Detect Special Numbers as a matter of course.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
zmix
Posts: 4
Joined: Sun Mar 24, 2024 12:12 am

Re: Cannot sort by Date because the data didn't include leading zeros.. help?

Post by zmix »

FJCC wrote: Sun Mar 24, 2024 2:15 am In the Text Import dialog that you should get as part of importing a csv file, there is a table at the bottom showing a few rows of data and the data type under which they will be imported. The default type is Standard. Right click on the word standard and pick something appropriate for the column. Your date column should work with the mdy setting and your numbers should work with US English.
And, as robleyd said, click Detect Special Numbers as a matter of course.
Thank you for the help..

I ended up using Microsoft Excel and when I imported the csv data it immediately recognized that there was numerical data entered as text (thanks Paypal geniuses!) and asked if I wanted them converted before importing the data.

It seems that Open office could use some help screens like that..!
Open Office 4.1.5 macOS 10.14.6
Post Reply