How to Sort CSV File in Excel (2 Quick Methods)

Get FREE Advanced Excel Exercises with Solutions!

Working with a CSV file in Excel is very common when you have data with names and addresses, product information, listing objects, and lots more. But when the dataset is large, then things get a little complicated. This is when we need to sort CSV files in Excel. Therefore, in this article, we will learn how to sort a CSV file in excel with 2 quick methods.


What Is CSV File?

Before starting the process of sorting, let us know CSV in a nutshell. The term CSV stands for Comma Separated Values. It allows you to store data in a text or tabular format. It is a plain text file that makes website development quite easy. CSV files are also used widely in the e-commerce business.  It is a very handy file type to import into an Excel spreadsheet or any other platform for a large database.

You can easily recognize a CSV file by its name. Because the file name contains the extension .csv beside it.


How to Sort CSV File in Excel: 2 Quick Methods

We can sort a CSV file in Excel in two formats. Either it can be with columns in a table format, or without columns in a text format. In the following section, we will discuss both of them through a step by step process. So without any delay, let’s hop into the procedure.

1. Sort CSV File Automatically with Columns in Excel

Let’s see the process of sorting a CSV file with columns automatically.

  • In the beginning, create a text file like this with the information of Product, Quantity and Sales Amount for 5 types of fruits.

Sort CSV File Automatically with Columns in Excel

  • Then, open a new Excel workbook.
  • In this blank workbook, go to the Data tab and click on Get Data under the Get & Transform Data group.

  • Afterward, select From Text/CSV under the From File group in the drop-down section.

  • Following, select the CSV file from your device folder and press Import.

  • Accordingly, you will see the preview window.
  • Here, select the File Origin as 65001: Unicode (UTF- 8) and Delimiter as Comma.

  • After this, press Load and you will get the CSV file in Excel.

  • Next, select the cell range D3:D7 and right-click on it.
  • Following, choose the Format Cells option in the Context Menu.

  • Then, select Accounting in the Number section and change the Symbol according to your preference.
  • Lastly, press OK to get the Sales Amount as per the CSV file.

  • Now, for sorting the dataset, go to the Data tab and select Sort.

Sort CSV File Automatically with Columns in Excel

  • Afterward, select the category Quantity in the Sort by section.
  • Along with it, select the order Smallest to Largest under the Order section in the Sort window.

Sort CSV File Automatically with Columns in Excel

  • Finally, you will get the CSV file with columns in a sorted way like this.

How to Sort CSV File in Excel

  • Additionally, if you need to filter the CSV file, simply click on the Filter icon beside any of the headers.
  • Then, filter the category in the Text Filters section.

Sort CSV File Automatically with Columns in Excel

  • That’s it, as you deselected Kiwi and Orange, the final output is not showing the information related to these categories.

Read More: How to Keep Leading Zeros in Excel CSV Programmatically


2. Organize CSV File in Excel Without Column

Another method of sorting a CSV file is to import and sort without columns. For illustration, we will take the same Excel file that we created in the first method. Let’s see the process below.

  • Firstly, go to the File tab of the workbook.

Organize CSV File in Excel Without Column

  • Then, click on Save As from the left panel.

  • Following, select CSV UTF-8 (Comma delimited) (*.csv) as the file type and press Save.

  • Accordingly, you will get the CSV file as text and without columns like this.

  • Next, ornament the dataset from the Font section in the Home tab.

  • Therefore, the dataset will look like this.

  • Now, let us sort this CSV file.
  • To do this, go to the Home tab and click on Sort & Filter.

Organize CSV File in Excel Without Column

  • Following, select any of the options in the drop-down menu for sorting the file.

Organize CSV File in Excel Without Column

  • Otherwise, select Custom Sort to sort it more precisely.

Organize CSV File in Excel Without Column

  • Then, select the category Sales Amount in the Sort by section.
  • Along with it, choose the Order as Largest to Smallest.

Organize CSV File in Excel Without Column

  • Lastly, press OK and you will successfully sort the CSV file like this.

  • Additionally, you can filter the dataset by clicking on the Filter icon in the Sort & Filter drop-down.

  • Following, you will notice the filter icon beside each header title.
  • Finally, you can filter the dataset according to your preference as we described in the first method.

Note: If you are using Excel Online or any version other than Excel 365 then you need to freeze the header row before sorting. Otherwise, the header row will act as other cells and get sorted along with cells.

To freeze this, select the immediate next row of the header > go to the View tab > select Freeze Panes in the Window group.

Read More: Paste Comma Separated Values into Excel


Download Practice Workbook

Download this sample file to practice by yourself.


Conclusion

Finally, we are concluding our article. I hope that it was a helpful one on how to sort CSV file in excel with 2 quick methods. Let us know if you have any other methods to sort CSV files.


Related Articles


<< Go Back to Import CSV to Excel | Importing Data in Excel | Learn Excel

What is ExcelDemy?

ExcelDemy - Learn Excel & Get Excel Solutions Center provides online Excel training , Excel consultancy services , free Excel tutorials, free support , and free Excel Templates for Excel professionals and businesses. Feel free to contact us with your Excel problems.
Sanjida Mehrun Guria
Sanjida Mehrun Guria

Hello! Welcome to my blog. I have completed my Bachelor in Architecture from Ashanullah University of Science & Technology, Dhaka. I am a passionate, goal-oriented person with an immense thirst for knowledge and an attitude to grow continuously. Besides Architectural work, I find it very enthusiastic to work in Excel blogging. Exceldemy is a platform where I have got the opportunity to flourish my skill in Microsoft Excel and therefore, here I will be posting blogs related to... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo