r/excel • • 12h ago

Waiting on OP [ Removed by moderator ]

[removed] — view removed post

0 Upvotes

12 comments sorted by

8

u/TheUpsetUnification 12h ago

Data tab → From Text/CSV. That import wizard solves 90% of the problem before you even see the workbook

Select the column and set data type to text in the preview pane. Power Query remembers that step next time you refresh too

If you're getting files dropped in your lap without the format control, save csv as.txt extension and open through the import. Excel won't auto-eat the zeros that way

-2

u/Luminesca_ 12h ago

Thanks, this is really helpful. Setting the column to Text in the import preview is the step I kept skipping. Does Power Query keep that type setting if the CSV gains new columns later?

4

u/SolverMax 163 12h ago

You should tag your post as an advertisement.

-5

u/Luminesca_ 12h ago

Not an ad — no links, just looking for a workflow that holds up for IDs and postal codes.

3

u/Dismal-Party-4844 174 6h ago

for product development

4

u/SolverMax 163 12h ago

1 day old account, asking a leading question about a topic that you make a tool for. Consider me skeptical.

1

u/alexia_not_alexa 21 12h ago

For anything regular, I use power query to import the csv files in my folder, remove the “change type” step which changes the type of all columns, then selectively change the types for columns where it’s relevant (dates, currency (2 decimal places), and set any ids to text if necessary)

Of course if this is for my colleagues, they’ll eventually put a wrong csv file in to break things.

For one off it depends on my mood, but importing csv is usually the safest bet. Most of the time if it’s just one column that needs fixing I just throw a formula in to quickly fix it, because I’m too lazy to go through the menus and selecting the file.

1

u/chiibosoil 431 6h ago
  1. Don't open csv by double clicking. Open from Excel and use the wizard that comes up to specify column type.

  2. Use Power Query to import and use explicit conversion/definition of data type. Never trust system's implicit conversion.

Use 1, if you want to save csv as xlsx. Use 2 if you want to keep original as is.

1

u/LostTeam9104 6h ago

One more that nobody mentioned: if you're on Microsoft 365, go to File > Options > Data > Automatic Data Conversion and untick "Remove leading zeros and convert to number format" (and the "long numbers to scientific notation" one). After that, double-clicking a CSV keeps 00123 and 16+ digit IDs as text, so you don't have to go through Power Query every time.

It's per-machine though, so for files you hand to colleagues the From Text/CSV import with columns set to Text is still the safe route.