[:sr]Učitavanje/prevlačenje podataka iz CSV u Excel [:en]LOADING/DRAG DATA FROM CSV TO EXCEL[:]

[:sr]Učitavanje/prevlačenje podataka iz CSV u Excel datoteku je isto kao i kod čarobnjaka za TXT format kada koristimo delimiter za razdvajanje kolona tabele. Takav posao možemo obaviti na dva načina, prvi, kada možemo upotrebiti Open (biramo tip datoteke CSV) postoji najmanje od verzije 2003 i drugi, kada koristimo PowerQuery koji postoji od verzije 2010 kao dodatna, a od 2016 kao podrazumevana funkcionalnost.

U verzijama: 2003, 2007, 2010, 2013, 2016, 2019, 2021, 365, za Mac i za web

Izgled CSV datoteke
Izgled CSV datoteke

Učitavanje CSV datoteke jednostavnom OPEN funkcijom

CSV (eng. Comma-Separated Values – vrednosti razdvojene zarezom) je u osnovi TXT format u kojem su vrednosti po kolonama razdvojene zarezom. To je tačno ako nam je u Windowsu postavljeno regionalno podešavanje sa engleskim pravopisom.

Upotreba znaka [ ; ] (polukolona) u CSV datoteci

Kada u Windows-u postavimo regionalno podešavanje sa srpsko-hrvatskim pravopisom (i drugim varijacijama) znak za razdvajanje decimalnih brojeva je zarez (,) tada se zbog ispravnosti CSV formata za razdvajanje kolona umesto zareza [ , ] koristi znak polukolona [ ; ]

Prilikom izvoženja podataka ovi znaci će biti podrazumevani prema trenutnom podešavanju. Ako kojim slučajem nam treba privremena promena tih znakova neophodno je u tabu File izabrati Options, i u kartici Advanced deštiklirati opciju Use system separators, kada postaju dostupne ćelije za korisničko podešavanje.

Podešavanje separatora
Podešavanje separatora

Veličina CSV datoteke je određena operativnim sistemom i za FAT16B može biti 2GB, za FAT32 – 4GB, HFS – 2GB, itd. Što omogućava da snimite tabelu od 10 kolona (svaka kolona po 10 bajtova) i skoro 20 miliona redova, naravno ako imate program koji može generisati ili Notepad koji može ispisati toliku datoteku.

Tu svakako nismo zaboravili ni delimiter (oznaka za razdvajanje kolona) koja može biti: Tabulator (znak TAB – ASCII kod karaktera 009) , tačka-zarez, zarez, razmak, ili korisnički definisan znak. Isto tako ne zaboravimo da je u excelu maksimalno dozvoljena tabela od  1.048.576 redova i 16.384 kolone.

To je ujedno i ograničenje za ovu vrstu učitavanja podataka za daljnju obradu.

Znači da sve obrade više od milion redova radimo upotrebom PowerQuery i PowerPivot funkcionalnostima.

Čarobnjak za prevlačenje podataka

Možete da otvorite tekstualnu datoteku koju ste kreirali u drugom programu kao Excel radnu svesku pomoću komande Open. Otvaranje tekstualne datoteke u Excel-u ne menja format datoteke — ovo možete videti u naslovnoj traci Excel-a, gde ime datoteke zadržava ekstenziju tekstualne datoteke.

  • Idite na File> Open i potražite lokaciju koja sadrži tekstualnu datoteku.
    Izaberite CSV datoteku na padajućoj listi tipa datoteke u dijalogu Open.
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Prevučeni podaci biće kao na prethodnoj slici.
  • Nakon klika na Open dugme pokrenuće se čarobnjak za pomoć u tri koraka.

Prvi korak

  • Od vas očekuje da odredite da li ćete za razdvajanje vrednosti po kolonama koristiti posebni znak za razdvajanje (delimiter sinonim je separator) kolona ili ćete brojem znakova odrediti širinu za sve redove.
  • Čarobnjak preporučuje kodni raspored teksta (UTF-8) kao i mogućnost štikliranja da li je u prvom redu zaglavlje tabele (My data has headers.)
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Kada završite izbor opcija kliknite dalje (Next>).

Drugi korak

  • Traži da odredite znak za razdvajanje kao što je Tabulator (Tab), tačkazarez/polukolona (Semicolon), zarez (Comma), razmak (Space) ili neki drugi znak koji sami odredite (Other).
  • U slučaju da imate uzastopne znakove razdvajanja, npr, duplirani, triplirani, štiklirajte i samostalni kvadrat za tretiranje uzastope znakove razdvajanja kao jedan (Treat consecutive delimiters as one).
  • I na kraju odredite navodnike za tekstove (Text qualifier).
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Kada završite izbor opcija kliknite dalje (Next>).

Treći korak

  • Od vas se sada očekuje da za svaku kolonu iz CSV datoteke odredite tip podataka.
  • Podrazumevana vrednost je Opšti format (General), može biti i tekst, (Text), datum (Date) određene pravopisne forme (DMY, dan, mesec i godina), ili da neku kolonu jednostavno i ne prevučete-importujete (Do not import column (skip)).
  • Ovde jednostavno možete sve ostaviti u postojećem opštom formatu.
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Kada završite izbor opcija kliknite završetak (Finish).
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Dobijeni sadržaj kao na prethodnoj slici možete formatirati selekcijom svih kolona i dovođenjem miša na liniju između kolona (crvena strelica) možete dvostrukim klikom formatirati širine kolona kao na sledećoj slici.
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Sada jednostavno izaberite bilo koju ćeliju i pozivom prečice Ctrl+T kreirajte tabelu.
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV
  • Ne dirajući ni jednu opciju izborom na OK, dobijate objekat tabelu o kojoj možete više pročitati u tekstu Kako kreirati Excel tabele.
Prevuceni podaci iz CSV
Prevučeni podaci iz CSV

Prevlačenje upotrebom PowerQuery

U slučaju da radimo sa više od milion redova u tabeli (snimljenih u CSV formatu) jedini način da to obavimo u Excel-u je upotreba PowerQuery funkcionalnosti. PowerQuery je dodatak u verzijama 2010 do 2016 i mora se naknadno instalirati, a u verziji 2019, 2021 i 365 on je nezaobilazna funkcija na tab-u Data.

Kada otvorite tab Data prvi alat na traci vam je Get Data. U prvoj opciji From File odaberite From Text/CSV, kao na sledećoj slici.

Prevuceni podaci iz CSV
Prevučeni podaci iz CSV

U dijalogu za izbor datoteke (Files) odaberite folder i datoteku CSV formata koju želite da učitate. Nakon informativnog prozora za konekciju na datoteku otvara se sadržaj kao na sledećoj slici:

Prevuceni podaci iz CSV
Prevuceni podaci iz CSV

Kada učitavamo podatke iz CSV formata i ne znamo koji znak razdvaja podatke po kolonama, separator će biti prepoznat u koloni Delimiter kao na sledećoj slici.

Prevuceni podaci iz CSV
Prevučeni podaci iz CSV

Sada je dovoljno klikom na Load, učitati podatke.

Ako neko ipak želi da transformiše podatke pre učitavanja neka pozove PowerQuery Editor, čiju upotrebu smo detaljnije objasnili u prilogu Prevlačenje-učitavanje-importovanje iz TXT formata.

Prevuceni podaci iz CSV
Tabela sa prevučenim podacima iz CSV
[:en]Loading/drag data from CSV to Excel file is the same as TXT format wizard when we use delimiter to separate table columns. We can do this kind of work in two ways, first, when we can use Open (choose the CSV file type), which has existed at least since version 2003, and second, when we use PowerQuery , which has existed since version 2010 as an additional, and since 2016 as a default functionality.

In  versions : 2003, 2007, 2010, 2013, 2016, 2019, 2021, 365, for  Mac  and for  the web

CSV file layout
CSV file layout

Loading a CSV file with a simple OPEN function

CSV (Comma-Separated Values) is basically a TXT format in which column values ​​are separated by commas. This is true if we have the regional setting in Windows set to English spelling.

Using the character [ ; ] (semi-column) in the CSV file

When we set the regional setting in Windows with Serbo-Croatian spelling (and other variations), the character for separating decimal numbers is a comma (,) then, due to the correctness of the CSV format, the comma [ , ]  is used instead of the comma [ ; ]

When exporting data, these characters will default to the current setting. If by any chance we need a temporary change of those characters, it is necessary to select Options in the File tab , and in the Advanced tab, uncheck the Use system separators option , when cells for user settings become available.

Adjusting the separator
Adjusting the separator

The size of the CSV file is determined by the operating system and can be 2GB for FAT16B, 4GB for FAT32, 2GB for HFS, etc. Which allows you to record a table of 10 columns (each column of 10 bytes) and almost 20 million rows, of course if you have a program that can generate or Notepad that can print such a file.

We certainly didn’t forget the delimiter, which can be: Tab (TAB character – ASCII character code 009), semicolon, comma, space, or user-defined character. Also, let’s not forget that the maximum allowed table in Excel is 1,048,576 rows and 16,384 columns.

This is also a limitation for this type of data upload for further processing.

It means that we do all the processing of more than a million rows using PowerQuery and PowerPivot functionalities.

Drag data wizard

You can open a text file that you created in another program as an Excel workbook using the Open command. Opening a text file in Excel does not change the file format — you can see this in the Excel title bar, where the file name retains the text file extension.

  • Go to  File >  Open  and browse to the location that contains the text file.
    Select  a CSV file from the File type drop-down list in the Open dialog  .
Drag data from CSV
Drag data from CSV
  • The dragged data will be as in the previous picture.
  • After clicking the Open button, a three-step help wizard will be launched.

The first step

  • You are expected to determine whether you will use a special character to separate the columns (delimiter is a synonym for separator) or whether you will determine the width for all rows by the number of characters.
  • The wizard recommends the code layout of the text (UTF-8) as well as the option to check if the table header is in the first row (My data has headers.)
Drag data from CSV
Drag data from CSV
  • When you have finished selecting options, click Next> .

Second step

  • It asks you to specify a separator character such as Tab ( Tab ), Semicolon ( Semicolon ), Comma ( Comma ), Space ( Space ) or some other character you specify ( Other ).
  • In case you have consecutive delimiters, for example, duplicated, tripled, check the independent box to treat consecutive delimiters as one ( Treat consecutive delimiters as one ).
  • And finally set the quotation marks for texts ( Text qualifier ).
Drag data from CSV
Drag data from CSV
  • When you have finished selecting options, click Next> .

The third step

  • You are now expected to specify a data type for each column from the CSV file.
  • The default value is General format ( General ), it can also be text , date ( Date ) in a certain orthographic form ( DMY , day, month and year), or simply do not drag and import a column ( Do not import column (skip) ).
  • Here you can simply leave everything in the existing general format.
Drag data from CSV
Drag data from CSV
  • When you have finished selecting the options, click Finish .
Drag data from CSV
Drag data from CSV
  • You can format the resulting content as in the previous image by selecting all the columns and by moving the mouse to the line between the columns (red arrow), you can double-click to format the width of the columns as in the following image.
Drag data from CSV
Drag data from CSV
  • Now simply select any cell and use the shortcut Ctrl+T to create a table.
Drag data from CSV
Drag data from CSV
  • Without touching any option by selecting OK, you get a table object, which you can read more about in the text How to create Excel tables .
Drag data from CSV
Drag data from CSV

Drag using PowerQuery

In case we work with more than a million rows in the table (recorded in CSV format), the only way to do it in Excel is to use the PowerQuery functionality. PowerQuery is an add-on in versions 2010 to 2016 and must be installed afterwards, and in versions 2019, 2021 and 365 it is an indispensable function on the Data tab.

When you open the Data tab , the first tool on the ribbon is Get Data . In the first From File option , select From Text/CSV , as in the following image.

Drag data from CSV
Drag data from CSV

In the file selection dialog (Files), select the folder and the CSV format file you want to upload. After the information window for connecting to the file, the content opens as in the following image:

Drag data from CSV
Drag data from CSV

When we load data from CSV format and we do not know which character separates the data by column, the separator will be recognized in the Delimiter column as in the following image.

Drag data from CSV
Drag data from CSV

Now it is enough to click on Load to load the data.

If someone still wants to transform the data before loading, they should call the PowerQuery Editor, the use of which we explained in more detail in the attachment Dragging-loading-importing from TXT format .

Drag data from CSV
Table with dragged data from CSV
[:]
5/5 - (1 vote)