Skip to content

Lesson 36 of 92 · Free Excel Course

Excel

Import Data into Excel: CSV, Text, PDF and Web (Plus Export to CSV, PDF and Google Sheets)

Import data into Excel from CSV, text, PDF and web pages without losing leading zeros or breaking dates. Export to CSV, CSV UTF-8, PDF and Google Sheets.

Sooner or later someone sends you data that didn't start life in Excel: a CSV export from a bank or web shop, a text file from an old system, a table in a PDF, or a list on a web page. Getting it in is easy. Getting it in without Excel quietly changing it is the real skill: order 00417 becomes 417, and 2 March becomes February 3. This lesson shows the right way to import each kind of file, how to fix the two classic problems, and how to send data back out as CSV, PDF or a Google Sheet.

Open a CSV, or import it?

A CSV (comma-separated values) file is plain text: one row per line, commas between the values. Here's one line from the practice file:

A200417,Ann Lee,NJ,02/03/2026,149.50
AB
1Raw line (orders.csv)ZIP (zeros lost)
200417,Ann Lee,NJ,02/03/2026,149.507302
300418,Ben Ortiz,MA,15/03/2026,89.002108
400419,Carla Diaz,NY,01/04/2026,240.2510001
500420,Dev Patel,CT,12/04/2026,35.756103
600421,Ella Brown,ME,30/04/2026,410.004101
700422,Femi Okafor,NJ,05/05/2026,120.008540
Order ID, customer, state, order date (day/month/year, from a UK supplier) and amount, all in one cell. Column B shows ZIP codes that already lost their leading zero.

You have two ways to get a file like this into Excel:

Double-click the file (or File, Open)Data, then From Text/CSV
What happensOpens straight away in a new workbookShows a preview first, then loads a table
Data typesExcel guesses every columnYou choose, or switch the guessing off
Leading zeros, odd datesOften changedKept, if you set the column to Text
Updates laterNoYes, with Refresh

Opening is fine for a quick look. For anything you'll keep, import.

Import a CSV or text file step by step

  1. Open a blank workbook and click the Data tab.
  2. In the Get & Transform Data group, click From Text/CSV (or Get Data, From File, From Text/CSV).
  3. Pick the file and click Import. A preview box opens.
  4. Check the three drop-downs at the top:
    • File Origin is the character set. If accents show as odd symbols, choose the UTF-8 option (65001).
    • Delimiter is usually detected (Comma). Change it to Semicolon or Tab if everything sits in one column.
    • Data Type Detection is set to the first 200 rows. Choose Do not detect data types to bring every column in as text, which protects IDs and odd dates.
  5. Click Load to put it on a new sheet, or Transform Data to clean it first in the Power Query Editor. There, click a column's type icon and pick Text for IDs, or right-click a date column and use Change Type, then Using Locale with English (United Kingdom) for day-first dates.

Because this is a Power Query import, the table remembers the file. Next month, save the new CSV over the old one and click Data, Refresh All. To clean imported data automatically every time, see Power Query and Power Pivot.

On a Mac (Microsoft 365, version 16.69 or later), use Data, then Get Data (Power Query), and choose Text/CSV. In Excel for the web, Power Query can only reach a CSV stored in OneDrive or SharePoint, so it's usually easier to open the CSV in the desktop app, or paste its contents into the sheet and use Text to Columns.

Why Excel drops leading zeros and changes dates

Double-click the practice CSV on a computer set to US dates and this is what you get:

ABCDE
1417Ann LeeNJ2/3/2026149.5
2418Ben OrtizMA15/03/202689
3419Carla DiazNY1/4/2026240.25
The zeros are gone from the IDs. 02/03/2026 (2 March) became February 3, 15/03/2026 stayed as text because there's no month 15, and 01/04/2026 (1 April) became January 4.

Two separate things went wrong:

  • Leading zeros. Excel sees 00417 as a number, and a number doesn't have leading zeros. The same thing happens to ZIP codes, phone numbers and account numbers. Numbers longer than 15 digits (card numbers, some IDs) lose their last digits too, because Excel only keeps 15 significant digits.
  • Dates. Excel reads dates in your computer's order. A day-first date is either flipped (when the day is 12 or under) or left as text (when it isn't). That's worse than an error, because the flipped ones look right.

The fixes:

  1. Import, and set the column to Text (previous section). This is the most reliable fix.
  2. Switch off automatic conversions in Excel for Microsoft 365 or Excel 2024: File, Options, Data, then under Automatic Data Conversion untick Remove leading zeros from numerical text and convert to a number and the date option. On a Mac it's Excel, Preferences, Edit. These settings apply when you open a CSV; they don't change Power Query imports.
  3. Rebuild lost zeros with a formula when you only have the damaged numbers: =TEXT(B2,"00000") turns 7302 back into the text "07302". A custom number format of 00000 does the same for display.

Changing the cell format after the damage doesn't bring zeros back, and a flipped date can't be told apart from a real one. Go back to the original file and import it properly.

Split one column into many with Text to Columns

Sometimes the data is already in Excel but stuck in one column, as in column A of the Practice sheet. Text to Columns splits it and lets you choose each column's type.

  1. Select A2:A7.
  2. Click Data, then Text to Columns.
  3. Choose Delimited and click Next.
  4. Tick Comma (untick anything else) and check the preview. Click Next.
  5. Under Data preview, click the first column and choose Text under Column data format. Click the fourth column, choose Date and pick DMY from its list.
  6. Change Destination to $D$2 so the raw lines stay put, and click Finish.
G23/2/2026
DEFGH
1OrderIDCustomerStateOrder dateAmount
200417Ann LeeNJ3/2/2026149.5
300418Ben OrtizMA3/15/202689
400419Carla DiazNY4/1/2026240.25
500420Dev PatelCT4/12/202635.75
600421Ella BrownME4/30/2026410
700422Femi OkaforNJ5/5/2026120
The result in D1:H7. IDs keep their zeros, and every date is now a real date read day-first: 2 March shows as 3/2/2026 on US settings. The amounts add up to 1,044.50.

Text to Columns is on the Data tab on a Mac too, and in Excel for the web. It's a one-off: unlike an import, it won't update.

Prefer formulas? In Excel for Microsoft 365, =TEXTSPLIT(A2,",") spills the five pieces into five cells, all as text, so 00417 keeps its zeros. =TEXTBEFORE(A2,",") gives just the ID, and =TEXTAFTER(A2,",",-1)*1 gives the amount (multiplying by 1 turns the text "149.50" into a number). To turn the text 02/03/2026 (in D2) into a real day-first date, use =DATE(RIGHT(D2,4),MID(D2,4,2),LEFT(D2,2)). The practice workbook's Answers sheet does all of this. For more on these functions, see Text functions and Dates and times.

Export: CSV, CSV UTF-8 and PDF

On Windows, click File, then Save a Copy (or Save As), and pick a format in the Save as type list. On a Mac, use File, Save As and the File Format list.

FormatKeepsLosesUse it for
Excel Workbook (.xlsx)EverythingNothingNormal saving
CSV UTF-8 (Comma delimited)Values of the current sheet, all charactersOther sheets, formulas, formattingUploading to apps, names with accents
CSV (Comma delimited)Values of the current sheetOther sheets, formulas, formatting, some charactersOld systems that ask for plain CSV
PDFThe printed lookEditingSending a finished report

Excel warns that only the current sheet will be saved and some features might be lost. That's expected for CSV: save your .xlsx too, and export a copy. Leading zeros survive only if the cells hold text (as after the import above).

PDF: choose PDF in the list, then click Options and pick Active sheet(s), Entire workbook or Selection. Standard gives print quality; Minimum size gives a smaller file. Set the print area and page layout first, as in Printing, or the PDF will split columns across pages.

Excel for the web: File, Export, Download this sheet as CSV (.csv) saves the current sheet. Microsoft says this export only supports ASCII characters, so accents may not survive; use the desktop app for CSV UTF-8. For a PDF, use File, Print, Print, and save as PDF from the print box.

PDF to Excel

In Excel for Microsoft 365 on Windows:

  1. Click Data, Get Data, From File, From PDF.
  2. Pick the PDF and click Open.
  3. In the Navigator, click each table or page listed on the left to preview it. Tick Select multiple items to take several.
  4. Click Load, or Transform Data to tidy it first (removing header rows repeated on each page is a common fix).

From PDF isn't in Excel for Mac or in the standalone Office 2016 and 2019 versions. It reads PDFs that contain real text; a scanned page is just a picture, so you'd need a tool with text recognition (OCR) first. Always check the totals after importing: merged cells and wrapped text in a PDF can shift values into the wrong column. If you need the PDF's text as an editable document rather than a table, our free PDF to Word converter is the better tool.

Copy tables from the web

Copy and paste is fine for a one-off. Select the table on the page, press Ctrl+C, click a cell in Excel and press Ctrl+V. If you get the site's fonts and colors, click the Paste Options button and choose Match Destination Formatting. Check numbers afterwards: they sometimes paste as text.

From Web gives a table you can refresh, handy for exchange rates or league tables:

  1. Click Data, then From Web (or Get Data, From Other Sources, From Web).
  2. Paste the page address and click OK.
  3. In the Navigator, pick a table from the suggested tables and click Load.

It works best on pages with real HTML tables. On a Mac, From Web isn't in Microsoft's list of Power Query sources, so use copy and paste.

Excel and Google Sheets, both ways

  • Excel to Google Sheets: upload the .xlsx to Google Drive and double-click it. You can edit it as an Excel file (changes are saved in Excel format), or choose File, Save as Google Sheets to make a Sheets copy. Inside an open sheet you can also use File, Import, Upload.
  • Google Sheets to Excel: in Sheets choose File, Download, Microsoft Excel (.xlsx), then open the file in Excel.

Most formulas, formatting and charts make the trip, but not all. Functions that exist only in Sheets (such as QUERY) or only in Excel won't calculate on the other side, and macros don't carry over. Check the totals after converting.

Try it yourself

Download the practice workbook. The Your task sheet has the steps.

  1. On Practice, select A2:A7 and use Text to Columns with Comma, column 1 as Text and column 4 as Date (DMY), destination D2.
  2. Check D2 shows 00417 and G2 is 2 March 2026. The amounts should total 1,044.50.
  3. In I2, type =TEXT(B2,"00000") and fill down to rebuild the ZIP codes (07302, 02108...).
  4. Save a copy of the Practice sheet as CSV UTF-8, then import that CSV into a new workbook with Data, From Text/CSV, setting OrderID to Text.
  5. Save the Practice sheet as a PDF of the active sheet.

The Answers sheet does the same splits with TEXTSPLIT, TEXTBEFORE, TEXTAFTER, DATE and TEXT formulas, so you can compare.

Common mistakes

  • Double-clicking a CSV you care about. Import it instead, so you choose the column types.
  • Fixing the format after the damage. Formatting can't bring back dropped zeros or un-flip dates. Re-import the original file.
  • Saving your only copy as CSV. Formulas, formatting and every other sheet are gone. Keep the .xlsx.
  • Forgetting day-first dates. Check a date with a day over 12; if it's left-aligned text, the whole column was read the wrong way round.
  • Trusting a PDF import blindly. Compare totals with the PDF.
  • Long numbers as numbers. Anything over 15 digits must be text, or the end digits become zeros.

What's next

You can now bring data in from CSV, text, PDF and the web without it being changed, and send it out as CSV, PDF or a Google Sheet. The previous lesson, Excel with AI and Copilot, shows how AI can help with tasks like this. Next, Excel skills tests and certification helps you prove what you've learned. You can also go back to the full Excel course. To turn imported text into numbers with a formula, see the VALUE function page.

Frequently asked questions

How do I open a CSV in Excel without losing leading zeros?

Don't double-click it. Use Data, then From Text/CSV, pick the file and click Transform Data. In the Power Query Editor, click the ID column's header, set Data Type to Text, then Close & Load. Quicker still: in the import box set Data Type Detection to Do not detect data types, which keeps every column as text. You can also use Text to Columns with the column format set to Text.

Why does Excel change my numbers into dates?

When you open a CSV, Excel guesses what each value is, so 3-4 or 02/03/2026 becomes a date using your computer's date order. A UK-style 02/03/2026 (2 March) turns into February 3 on US settings, and 15/03/2026 stays as text because there's no month 15. Import the file instead and set the column to Text, or use Change Type, then Using Locale in Power Query. Excel for Microsoft 365 also lets you switch off some of these conversions under File, Options, Data, Automatic Data Conversion.

What's the difference between CSV and CSV UTF-8?

Both are plain text with commas between values and both save only the current sheet. CSV UTF-8 stores every character correctly, including accents (é), other alphabets and symbols, so choose it for names and addresses. Plain CSV (Comma delimited) uses an older character set and can turn those characters into question marks.

How do I convert a PDF to Excel without Adobe?

In Excel for Microsoft 365 on Windows, use Data, Get Data, From File, From PDF, pick the file and choose the table in the Navigator. It works on PDFs that contain real text, not on scanned images. It isn't in Excel for Mac or in Office 2016 and 2019. If you need the PDF as an editable document rather than a table, try our free PDF to Word converter.

How do I save an Excel sheet as a PDF?

On Windows, File, Save a Copy (or Save As), choose PDF in the Save as type list, click Options to pick the active sheet, the whole workbook or a selection, and click Save. Set up the page first so it fits; see Printing. In Excel for the web, use File, Print, then save as PDF from the print box.

How do I convert an Excel file to Google Sheets and back?

Upload the .xlsx to Google Drive and open it with Google Sheets. You can edit it as an Excel file, or choose File, Save as Google Sheets to convert it. To go back, in Sheets choose File, Download, Microsoft Excel (.xlsx). Check formulas afterwards: a few functions exist in only one of the two programs.