Subscribe to How-To Geek Підписатись на How-To Geek

Important! This is an automatic machine translated page. If you can read english, you should Click Here to read the original English version of the article.

How To Import a CSV File Containing a Column With a Leading 0 Into Excel Як імпортувати CSV-файл, що містить Колонка з провідним 0 в Excel

Microsoft Excel will automatically convert data columns into the format that it thinks is best when opening comma-separated data files. Microsoft Excel автоматично конвертує дані стовпці в формат, що він думає, є кращим при відкритті кому файлів даних. For those of us that don't want our data changed, we can change that behavior. Для тих з нас, НЕ хочемо, щоб наші дані змінилися, ми можемо змінити цю поведінку.

You have a CSV file probably exported from other application or given to you by other people. Ви, ймовірно, CSV файлів, що експортуються з інших додатків або наданої іншим людям. You would like to open it up in Excel since you know it very well. Вам його б хотілося відкрити в Excel оскільки ви знаєте, це дуже добре. The CSV file will look like this (if you open the file in notepad.exe): CSV файлу буде виглядати наступним чином (якщо ви відкриваєте файл у notepad.exe):

The file contains columns: ProductModelID, Name, SpecialID, and ModifiedDate. Файл містить стовпці: ProductModelID, Ім'я, SpecialID і ModifiedDate. The column SpeicalID containing data with leading 0 and it is specialized code so you would like to keep the leading 0s in Excel. SpeicalID колонка, що містить дані з провідними 0 і спеціалізованих код, щоб ви хотіли б зберегти провідні 0s в Excel. Since it is a CSV file it is, by default, shown in your Windows Explorer as an Excel file: Так як CSV-файлу він, за замовчуванням, як показано в Windows Explorer у вигляді файлу Excel:

So you double-click the file and open the file in Excel as such: Таким чином, ви двічі клацніть файл і відкрити файл в Excel як таку:

You can see that by default, Excel stripped out the leading 0s in column 3 “SpecialID €?. Ви можете побачити, що за замовчуванням, Excel позбавили з провідними 0s у колонці 3 "SpecialID €?. You brought up Excel application and tried to use File/Open to open the file manually and that doesn't work either. Ви виховані додаток Excel і спробував використовувати Файл / Відкрити, щоб відкрити файл вручну, і що не працює ні. How can I fix this? Як я можу це виправити?

The trick is to rename the file with .TXT extension then bring the file into Excel. Весь фокус у тому, щоб перейменувати файл з розширенням. Розширенням TXT потім принести файл в Excel. SO first bring up “My Computer €? Отже, спочатку виховати "Мій комп'ютер" €? and navigate the folder to where the file resides. і відкрийте папку, в якій знаходиться файл.

Now, if you don't see the file extension .CSV (Windows has this option disabled by default) then follow this step to enable the file extension – Select the menu “Tools €?/ €?Folder Options €? Тепер, якщо ви не бачите розширення файлу. CSV (Windows має ця опція відключена за замовчуванням), потім йдуть цього кроку для того, щоб розширення файлу - виберіть у меню "Сервіс €? / €? Папки €? then select the “View €? потім виберіть команду "Відкрити €? tab, uncheck the item “Hide extensions for known file types €? Вкладка, зніміть пункту "Приховувати розширення для зареєстрованих типів файлів €? as the picture below: як на малюнку нижче:

Then you should see the file extension as such: Тоді ви повинні побачити розширення файлу такі як:

Right click the file and select rename to rename the file to become “ProductInfo.txt €? Клацніть правою кнопкою на файл і виберіть пункт Перейменувати, щоб перейменувати файл, щоб стати "ProductInfo.txt €?

Notice the icon changes to regular text file icon as well. Зверніть увагу на значок змін до регулярних значок текстового файлу, а також. No open up Excel and use “File €?/ €?Open €? Не відкривати Excel і використовуйте "Файл €? / €? Відкрите €? command to bring the file into Excel. Команда відправити цей файл в Microsoft Excel. When you do this, a dialog will pop up like: Коли ви це зробите, з'явиться діалогове вікно спливаюче як:

Make sure the “Delimited €? Переконайтеся, що "з роздільниками €? radio button is selected and click on “Next €? перемикач вибраний і натисніть кнопку "Далі €? button to continue. Кнопка для продовження. On the next screen, check the box “Comma €? На наступному екрані, встановіть прапорець "Comma €? and uncheck all other selections. і зніміть усі інші вибору.

Click on “Next €? Натисніть "Next €? to advance to the next screen. , Щоб перейти до наступного екрану. In this screen, you need to click on the “SpecialID €? У цьому екрані, ви повинні натиснути на "SpecialID €? column and select the “Text €? стовпці та виберіть "Текст €? radiobutton from the “Column data format €? RadioButton з колонки "€ формат даних? section. розділі.

Click on “Finish €? Натисніть кнопку "Готово" €? then you are done. Потім ви зробили.

You can see now the column “SpecialID €? Ви тепер бачите, колонка "SpecialID €? has been brought in as a Text column and all leading 0 are preserved. було доведено у вигляді збереглися колонки тексту і всі провідні 0.

This method can be applied to any special circumstance for bringing in a CSV file into Excel including other delimited files. Цей метод може бути застосований до будь-якої конкретної ситуації для залучення файлу CSV в Excel, включаючи інші файли з розділювачами. With the ability of specifying the data type for each column during the data importing process you are in much better control on your final result. Маючи можливість вказівки типу даних для кожного стовпця ході даного процесу імпорту ви знаходитесь у набагато більш ефективний контроль на кінцевий результат.

This article was originally written on 04/20/07 Tagged with: Ця стаття була спочатку написана на 04/20/07 тегами: Microsoft Excel Microsoft Excel , , Microsoft Office Microsoft Office

Daily Email Updates Email Щоденні оновлення

You can get our how-to articles in your inbox each day for free. Ви можете отримати наші довідкові статті у Вашу поштову скриньку щодня безкоштовно. Just enter your name and email below: Просто введіть ваші ім'я та адресу електронної пошти нижче:


Name: Ім'я:
Email: Електронна пошта:

Comments (10) Коментарі (10)

  1. Mikey Mac Майки Mac

    Another way to do this – especially if the column is of a fixed umber of chars like “SpecialID” above – you simply highlight the column or cells you want to fix, right-click, Format Cells…, click Custom on the Number tab, and type four zeros (or however many chars the field should be) and click OK. Ще один спосіб зробити це - особливо, якщо стовпець є фіксованою харіус символів, як "SpecialID" вище - ви просто виділіть стовпець або комірки, які потрібно виправити, клацніть правою кнопкою миші Формат клітинок ..., натисніть кнопку Інший на вкладці "Число, Тип і чотири нуля (або скільки символів на місцях повинна бути) і натисніть кнопку ОК. Excel will automatically pad the field with leading zeros. Excel автоматично PAD області з провідними нулями.

    The bonus to this method is that you can still do calculations with the number without having to use complex formulas to convert the text “number” into a real number. Бонус для цього методу є те, що ви можете виконувати обчислення з числом без використання складних формул для перетворення тексту "номер" на даний номер.

  2. Jim Millard Джим Міллард

    A third alternative, assuming you have control over the creation of the CSV, is to export the “SpecialID” field as a formula, eg, instead of exporting (0001), export (=”0001″). Третя альтернатива, якщо ви контролю над створенням CSV, є експорт в поле "SpecialID" як формули, наприклад, замість експорту (0001), експорт (= "0001"). That forces the value to be evaluated as text, as Excel evaluates the field as a text formula. Це змушує вартість, яка буде оцінюватися як текст, як Excel обчислює області у вигляді текстового формулою.

  3. Erin T Ерін Т

    Thank you! Спасибо! I was really struggling with this and appreciate the easy to follow instructions. Я був дійсно бореться з цим і цінувати лише дотримуватися інструкції. My problem is solved! Вирішується моя проблема!

  4. Paul F Поле F

    Thanks much. Завдяки багато. This page helped me a lot — exactly the info I was looking for. Ця сторінка мені дуже допомогли - саме інформацію я шукав.

  5. Prathap Prathap

    Thanks all. Спасибо всем. This helped to solve my problem. Це допомогло вирішити мою проблему.

  6. andrew marshall Ендрю Маршалла

    when importing part number from a csv file some number cotaining E При імпорті номером з CSV-файлу деяке число cotaining E
    eg 977012e000 when importing into excel 2007 the number end up looking like 9770+e can you please advise me how to fix this as every part number containing e is treated the same way. 977012e000 наприклад, при імпорті в Excel 2007 число до кінця схожа 9770 + е могли б ви допомогти мені радою як це виправити, як кожна частина числа, що містять е трактується однаково.

  7. Anon Anon

    Thanks Спасибо

  8. Vivek Вівек

    Jim's option worked for me. Опції Джим працював на мене. No need to manipulate the file later. Не треба маніпулювати файл пізніше.

    Thanks Спасибо

  9. husker Husker

    Jim's option is really simple when compared to other solutions out there and worked… thanks Джим варіантом є дуже простим у порівнянні з іншими рішеннями там і працювали ... спасибо

  10. tapas Тапас

    i still can't solve my problem, Я до сих пір не можуть вирішити мою проблему,
    its same свої ж
    can,t open my .csv excel files in office 2007. може, T відкрити. CSV Excel файлів в Office 2007.


Our Friends Наші друзі
Getting Started Приступаючи до роботи


About How-To Geek Про How-To Geek
What Is That Process? Що це за процес?
svchost.exe svchost.exe
jusched.exe jusched.exe
dwm.exe dwm.exe
ctfmon.exe Ctfmon.exe
wmpnetwk.exe wmpnetwk.exe
wmpnscfg.exe wmpnscfg.exe
rundll32.exe rundll32.exe
wfcrun32.exe wfcrun32.exe
Ipoint.exe Ipoint.exe
Itype.exe Itype.exe
Wfica32.exe Wfica32.exe
Mobsync.exe Mobsync.exe
conhost.exe conhost.exe
Dpupdchk.exe Dpupdchk.exe Adobe_Updater.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. Copyright © 2006-2009 HowToGeek.com. All Rights Reserved. Всі права захищені.