Java: Read a CSV File into an Array #49

  Рет қаралды 201,668

Alex Lee

Alex Lee

Күн бұрын

Пікірлер: 254
@alexlorenlee
@alexlorenlee 11 ай бұрын
If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h
@cristobalsanchez3829
@cristobalsanchez3829 4 жыл бұрын
System.out.println(“I love your videos”);
@sakshi8574
@sakshi8574 4 жыл бұрын
I'm an Engineer and graduated like a month ago. Not a single teacher in 4 years of my graduation taught me in such a good way ! Thank you Alex ❤️🇮🇳
@jglee6721
@jglee6721 3 жыл бұрын
I think Alex mentioned that he didn't have a good teacher thus he started these videos to help others. Thank God he is a world class teacher and 196K subs at this point in time speaks louder than words.
@paulhetherington3854
@paulhetherington3854 2 жыл бұрын
Like a, month ago? Bull sht-- e(ng)ineer -- racist... EINEER -- not E(ng)lish
@mannyokafor4609
@mannyokafor4609 4 жыл бұрын
Fifth! my fav youtuber if I am honest you deserve much more subs man just keep going Java is gonna get much more popular! Please do a video on annotations!
@martynbirdem189
@martynbirdem189 3 жыл бұрын
See this video I hope you will find it helpful. And you can subscribe also get the original code by mail. I have also get kzbin.info/www/bejne/o16QZZeahbKartE This is the channel link
@shazzadurrahman9750
@shazzadurrahman9750 4 жыл бұрын
1. How to skip the first row of headline 2. How to read the each row from csv file 3. How to write in csv file
@seelyw.4818
@seelyw.4818 3 жыл бұрын
1. put this in your while: if (values[0].equals("NameOfFirstHeading")) { continue; } else { code wich parses the columns }
@martynbirdem189
@martynbirdem189 3 жыл бұрын
See this video I hope you will find it helpful. And you can subscribe also get the original code by mail. I have also get kzbin.info/www/bejne/o16QZZeahbKartE This is the channel link
@Rajdeep11082
@Rajdeep11082 Жыл бұрын
To write into a file, try (PrintWriter pw = new PrintWriter(new FileWriter(file))) { pw.write(“data to append) } catch (IOException e) { // Handle the exception }
@Rajdeep11082
@Rajdeep11082 Жыл бұрын
It is not a good idea to read and write into the same file, it would be better to create a diff file for writing if you perform read operation simultaneously, and later if needed, files can be merged easily
@Kurokage130
@Kurokage130 4 жыл бұрын
Fourth! Alex you rock man this is exactly what I needed to analyze stock data! Are you a mind reader? =]
@BrandonCastillo-eo1or
@BrandonCastillo-eo1or 4 жыл бұрын
Lol. Are you taking any Udemy course?
@gabbishleegifted4752
@gabbishleegifted4752 3 жыл бұрын
That’s a good point this would be sufficient for that
@m4gg197
@m4gg197 4 жыл бұрын
4:34 BLESS YOU! The "wow" killed me 😂☕
@sanuMani1998
@sanuMani1998 3 жыл бұрын
same here , I was laughing the whole video with that wowww . 😂😂😂😂😂😂😂
@lesediseleke1416
@lesediseleke1416 4 жыл бұрын
If I could I'd reference Alex only in assignments cause this is so helpful
@morris4622
@morris4622 4 жыл бұрын
hi alex i love your vids about java but can you pls make a game with the JFrame plss
@luisvieira640
@luisvieira640 4 жыл бұрын
MC Noob26 Great suggestion!
@tiboomvds344
@tiboomvds344 4 жыл бұрын
I hope hé do it this Will be also good for gis vieus because that is much populier as a simpele turtorial
@aayamrai1215
@aayamrai1215 2 жыл бұрын
kzbin.info/www/bejne/nYLFZJd7Yt5kiZY
@aayamrai1215
@aayamrai1215 2 жыл бұрын
kzbin.info/www/bejne/nYLFZJd7Yt5kiZY
@zimt_g2375
@zimt_g2375 4 жыл бұрын
here for the cute Asian guy with additional java knowledge
@sheriffcrandy
@sheriffcrandy 4 жыл бұрын
Gay
@mngf749
@mngf749 4 жыл бұрын
@@sheriffcrandy homophobic
@williamtrillion992
@williamtrillion992 3 жыл бұрын
@@sheriffcrandy lmao
@harpreetjanday1660
@harpreetjanday1660 4 жыл бұрын
hi alex
@ap-pv7ug
@ap-pv7ug 4 жыл бұрын
You no longer need separate catch statements to catch each individual error. You can just use a vertical pipe to separate types.
@paulj19
@paulj19 4 жыл бұрын
second
@brianparsons5709
@brianparsons5709 3 жыл бұрын
Thank you for not only explaining yourself as you go, but also taking the time at the end to go back and explain the process line by line. You are a life saver!
@martynbirdem189
@martynbirdem189 3 жыл бұрын
See this video I hope you will find it helpful. And you can subscribe also get the original code by mail. I have also get kzbin.info/www/bejne/o16QZZeahbKartE This is the channel link
@yashsaxena7787
@yashsaxena7787 3 жыл бұрын
what if the data already has commas in it? like the address. The what to do??
@michaelsteele8402
@michaelsteele8402 4 жыл бұрын
found my problem
@axelpalomino2571
@axelpalomino2571 4 жыл бұрын
don't think if this is relevant, but can you make a video about creating a java multiple choice quiz using buttons. I am working on a project similar to this and I need help. Let me know what you think.
@axelpalomino2571
@axelpalomino2571 4 жыл бұрын
Please!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@bjr816
@bjr816 4 жыл бұрын
I can't wait for your course. You explain topics better than most people, move at constant pace, and provide great examples.
@alexlorenlee
@alexlorenlee 4 жыл бұрын
Thanks :)
@Kaname2907
@Kaname2907 4 жыл бұрын
Hey Alex is there a way to put a sound track into a java gui program?
@Aratussyitto
@Aratussyitto 4 жыл бұрын
You can use InputStream ! but just convert the files to .wav or .au
@Kaname2907
@Kaname2907 4 жыл бұрын
@@Aratussyitto I will try that! Thank you!
@OzozGaming
@OzozGaming 3 жыл бұрын
How would you separate a txt file into multiple txt files i.e. student2018.txt, student2019txt etc
@driesyperman8119
@driesyperman8119 4 жыл бұрын
Go to window -> preferences -> Run/Debug -> Console -> disable "Limit console output" . Now you can see all the output.
@christianw1490
@christianw1490 3 жыл бұрын
can you do the same tutorial for a 2 dimensiol array? Great video tho and very easy to understand
@anr_plays
@anr_plays 4 жыл бұрын
Show how to make your slot machine.
@jessechoe
@jessechoe 4 жыл бұрын
Again, The day I learn some topics in Java, you create the perfect video the eliminate my confusion. Thank You!
@martynbirdem189
@martynbirdem189 3 жыл бұрын
See this video I hope you will find it helpful. And you can subscribe also get the original code by mail. I have also get kzbin.info/www/bejne/o16QZZeahbKartE This is the channel link
@nityasridhar
@nityasridhar 3 жыл бұрын
Wait so which part of this is the array? I'm confused
@djuka8121
@djuka8121 4 жыл бұрын
This vid helped me a lot. Thank you Alex
@itscarine8786
@itscarine8786 3 жыл бұрын
hi, how do you sort arrays from the file? Let's say the length of the address from shortest to longest?
@JapanTravelShorts
@JapanTravelShorts 3 жыл бұрын
I want to know that as well
@morris4622
@morris4622 4 жыл бұрын
first
@youkeshgurung5280
@youkeshgurung5280 4 жыл бұрын
Bro, have you learned programming language by choosing IT course or you learn by yourself😀😀😀♥️♥️
@renecabuhan1675
@renecabuhan1675 4 жыл бұрын
He is a software engineer.
@mineclashtv9709
@mineclashtv9709 3 жыл бұрын
Why wouldn't you use the java.nio.file.Files class to read a file (from a Path object) as a String? It's a lot simpler and more readable this way. String[] values = Files.readString(Path.of("Path to file")).split(";"); (might throw an IOException) To get an array of single lines, you could either replace the split(";") with split(" "), get a List of all lines using Files.readAllLines(Path) or even a stream with Files.lines(path), though streams might be a little too advanced for beginners Iterating over the array is also easy: for(var value : values) System.out.println(value);
@uppalaadarsh3261
@uppalaadarsh3261 3 жыл бұрын
Can we ignore headers in file
@DarKingHell
@DarKingHell 2 жыл бұрын
te falto cerrar el archivo
@dhrutipatel5264
@dhrutipatel5264 3 жыл бұрын
My code is exactly the same still doesn't work shows the problems like Variable 'line' initializer '""' is redundant and 'catch' branch identical to 'IOException' branch can u help?
@kerimragimov5727
@kerimragimov5727 3 жыл бұрын
You can not imagine how you helped me out with my CS lab. Thank you Alex:)
@suchismitamohanty9010
@suchismitamohanty9010 8 ай бұрын
Hello Alex, I hope you are doing well.I wanna little guide from you..I have understood all the concepts of java but while I am trying for competitive coding I am unable to solve it..can you suggest how to be good at competitive coding
@jurgencampos8505
@jurgencampos8505 4 жыл бұрын
Just what i needed today! Thank you man!!
@paulhetherington3854
@paulhetherington3854 2 жыл бұрын
This isn't, the origin, EVrr of Java! Hence; illegally - get filesz! Under this Act: Loaned Land Act
@itaybroder2037
@itaybroder2037 4 жыл бұрын
yo Alax can you pls make a vid on maps and hashmaps in java? I really need it and love your videos mate:)
@renecabuhan1675
@renecabuhan1675 4 жыл бұрын
He made it already
@annalee9763
@annalee9763 2 жыл бұрын
thanks a lott these videos help, i am actually trying to make an app for parking since i forget to put parking . Can you help me make the app. this is how the app should work -> read the number see if it matches the number i put. -> read the timing till when the parking ticket lasts for and set alarms before the time provided . I cant find any KZbin channel that will help me in this problem, if you can please find the time to make a video on this. i would be very grateful thankyouuu soo much once again
@salehashamim7803
@salehashamim7803 3 жыл бұрын
Plz reply me. I am printing output in excel and input file is properties file. But output is coming with double quotes which I don't need. How to fix it.
@osamugaming1807
@osamugaming1807 3 ай бұрын
If you are using Windows and it seems there's an Exception showing up in String path just change the \ backslash to / forward slash
@Sinaiii
@Sinaiii 3 жыл бұрын
my scanner is skipping the last line to read because i have a while loop with the following condition: sc.hasNextLine() help
@StevenRafael268
@StevenRafael268 3 ай бұрын
Thank you so much for this super useful video! this saved my butt with my assignment haha
@johnmaravelis9568
@johnmaravelis9568 4 жыл бұрын
☕☕☕ Hey Alex, another great video thank you for helping us learning Java!! At some point you mentioned #RegEx, could you make a video explaining them?
@martynbirdem189
@martynbirdem189 3 жыл бұрын
See this video I hope you will find it helpful. And you can subscribe also get the original code by mail. I have also get kzbin.info/www/bejne/o16QZZeahbKartE This is the channel link
@davidhamilton9871
@davidhamilton9871 2 жыл бұрын
dude why are you using your desktop directory instead of the IDE folder that can be packaged together; cant use this
@ferfykins
@ferfykins 4 жыл бұрын
Excellent video, thanks Alex.
@morris4622
@morris4622 4 жыл бұрын
do you reply???
@FabianVirgen-gz9yl
@FabianVirgen-gz9yl 5 ай бұрын
You've taught me more than my college professor has... lol much love Alex
@hypnos9336
@hypnos9336 5 ай бұрын
MAN I wish I had seen this tutorial about a month ago. I was trying to write a similar program and for the life of me couldn't figure it out
@roneelkumar3269
@roneelkumar3269 2 жыл бұрын
HI. Alex can you tell how can we sort this file by book id with insertion or any sort or anyone has any idea about this. Thanx.
@ghostcavalry
@ghostcavalry Жыл бұрын
Thank you soo much it was exactly what I was looking for 2 days..
@lauraaltavilla399
@lauraaltavilla399 3 жыл бұрын
public void EscribeEnTextoCSV(String nombreFichero, boolean anyadir, Alumne al) { File f; f = new File(nombreFichero); boolean encabezado = false; if (f.exists() && !anyadir) { f.delete(); encabezado = true; } if (!f.exists()) { encabezado = true; } //Escribir con buffer para hacerlo línea a línea FileWriter flujoSalida = null; BufferedWriter salida = null; try { flujoSalida = new FileWriter(f, anyadir); salida = new BufferedWriter(flujoSalida); if (encabezado) { salida.write("nom;apellido;edat"); salida.newLine(); } String nom = al.getNom(); salida.write(nom); salida.append(";"); String apellido = al.getApellido(); salida.write(apellido + ";"); int edat = al.getEdat(); salida.write(Integer.toString(edat)); salida.newLine();
@loetonkukubane2424
@loetonkukubane2424 2 жыл бұрын
need help looping through a CSV file, checking and printing if it has duplicates or not.
@sanjaymarathe3763
@sanjaymarathe3763 3 жыл бұрын
are you an oracle certified java programmer? just asking :)
@akshithachennupati7278
@akshithachennupati7278 4 ай бұрын
could u please make a video on storing datasets into graphical neural networks using java
@mattnsac
@mattnsac Жыл бұрын
Found it entertaining that I know damn near ever street in that list. Go SacTown!
@latedeveloper7836
@latedeveloper7836 3 жыл бұрын
Does anyone know how to skip the header row? I have different data types but can't figure out a simple way to ignore the header row (all strings, whereas my data has doubles). Any help much appreciated!
@hemanthgowda3450
@hemanthgowda3450 Жыл бұрын
How to print a partical line in csv file instead of printing evrything can you please send me the code
@boshydbash9030
@boshydbash9030 4 жыл бұрын
making videos so simple gg alex lee liked vid
@xow9450
@xow9450 26 күн бұрын
what if the array youre using is for a class and not a primitive type
@magretrutendontokozoshone3366
@magretrutendontokozoshone3366 4 жыл бұрын
my first year lecturer, Alex Lee. thank you so much. this year has been tough :(
@JuanitO_o
@JuanitO_o 2 жыл бұрын
any idea why the csv that i made in excel separates the data with this ; instead of commas?
@johnbeesoo1634
@johnbeesoo1634 3 жыл бұрын
Hi how can I retrieve a specific data ,like for example a specific row and column?? the data being: car owner plateNo 1 a a1 2 b b1 3 c c2 I wanna retrieve only row 3 and column 3
@nickingraz6727
@nickingraz6727 4 ай бұрын
HOW DO I SELECT JUST ONE VALUE OF THE ARRAY AS A DOUBLE SOMEONE PLEASE HEEEELLLLLLPPPPPPPPP
@Ms_Oszy
@Ms_Oszy 2 жыл бұрын
thanks alot, what if file need to be fragments into m blocks ?
@anonym0us__537
@anonym0us__537 3 жыл бұрын
Thank you so much...😊🙏 . Just one doubt , Is it possible to search for a particular value,like just one name like "Alex" and the program will print all the corresponding values which we need..?
@adarmawan117
@adarmawan117 4 жыл бұрын
I think you need to explain between Scanner and bufferedReader or anything else to get input,.
@khoanguyenucang5534
@khoanguyenucang5534 2 жыл бұрын
hello guys, i have a range of date for example 03/01/2020 to 03/05/2020 in third column , and now how can calculate data from a fourth column that are corresponding to the third column, thank you guys !
@RaselAhmed-ix5ee
@RaselAhmed-ix5ee 3 жыл бұрын
please reply me its an urgent help by tonight i need to submit a program
@celestiaharpster4273
@celestiaharpster4273 2 жыл бұрын
Thanks for your excellent videos, you explain things so clearly. I say this with kindness I promise, but my 3 year old loves curious george and I couldn't help but notice you bear a striking resemblance to the man with the yellow hat, I say halloween costume idea.
@essaydnb
@essaydnb 2 жыл бұрын
why does it not read the titles of each column and instead start on line 2?
@djneverblock7300
@djneverblock7300 2 жыл бұрын
I swear this video was so helpful to me. i was looking for a more efficient method of scanning these than using a normal scanner method. you explained it in a clear way and easy for me to understand. thanks for saving my weekend :)
@andreviniciusbezerradasilv9335
@andreviniciusbezerradasilv9335 Жыл бұрын
thanks bro, your java content helped me a lot.
@F1rstNameLastName
@F1rstNameLastName 3 жыл бұрын
I spent 3 hours trying to figure out how to do this because my uni lecturer is awful at explaining things and makes everything overly complicated, but then I bumped into this and figured it out within the first 9 minutes.
@samsepiol7
@samsepiol7 9 ай бұрын
If I want to do the same thing but with 3 files, what do I do?
@shadowwmoses3721
@shadowwmoses3721 4 жыл бұрын
Can someone help me like for example I want just the row where the address = 1260 BELL AVE
@noone-hi6kq
@noone-hi6kq 4 жыл бұрын
Not bad, man. I hate almost all youtubers but it is good
@drcl7429
@drcl7429 2 жыл бұрын
Don't forget to do a close() on the bufferedreader. Best to put it in a Finally{} block following try-catch.
@nicoleuruchima595
@nicoleuruchima595 Жыл бұрын
THNAKS, you saved mi life.
@atomrofl693
@atomrofl693 10 ай бұрын
Hey, where can I find the scanner version of this?
@deinarudkova-schneider119
@deinarudkova-schneider119 2 жыл бұрын
OMG! you are just the best!!! :D Thank you!
@ibrahimcowke
@ibrahimcowke 3 жыл бұрын
He always says, Insha Allah. I think he is Muslim?
@umiuo8894
@umiuo8894 4 жыл бұрын
I can't take your java course because I don't wanna spend 15,000 INR
@HammtariProductions
@HammtariProductions Жыл бұрын
Thank you, you are saving me from failing my computer science test 🙂
@nuwaver91
@nuwaver91 2 жыл бұрын
Thank you very much for this useful tutorial! Just one thing, I didn't catch why we need at 11: String line = "";
@joeord4669
@joeord4669 4 жыл бұрын
hi how would you run queries on this like say i only wanted to see crimes that have been committed on a certain day for example?
@mcfirstempire
@mcfirstempire Жыл бұрын
Merci !
@CambrielMoore
@CambrielMoore 4 жыл бұрын
Hei Alex, how can you differenciate between a seperating comma and a comma which is used within a string of text? Like Story, #OfWords. foo, foofoo, 2 like i am working on a programm which lets you create quizzes on your own.. and i thought that csv files could be the thing how i store the quizzes :o
@AayushBartaula
@AayushBartaula 4 жыл бұрын
Please make videos for binary file also
@luttrell321
@luttrell321 4 жыл бұрын
What if I only wanted to read the first x number of lines of the file?
@adolfjamesurian6510
@adolfjamesurian6510 4 жыл бұрын
How do you insert data to txt file? Like to avoid making new object and deleting all the data inside the txt file? Can u make a tutorial
@jetonkrasniqi8762
@jetonkrasniqi8762 4 жыл бұрын
You are doing a great job, keep it up.
@hafpixels4172
@hafpixels4172 3 жыл бұрын
How come I didn't find your channel earlier 😕. I am amazed man♥️♥️.
@hafpixels4172
@hafpixels4172 3 жыл бұрын
You got a new subscriber
@eugenesmith9940
@eugenesmith9940 Жыл бұрын
Don't you need to close that reader (br)?
@1914abw
@1914abw 4 жыл бұрын
That move toward the end of your videos where you zoom out and show the entire code is so REFRESHING!!! Thanks a lot. Great job! Keep up the good work!
@martynbirdem189
@martynbirdem189 3 жыл бұрын
See this video I hope you will find it helpful. And you can subscribe also get the original code by mail. I have also get kzbin.info/www/bejne/o16QZZeahbKartE This is the channel link
@noahibarra3379
@noahibarra3379 2 жыл бұрын
what would the syntax look like for putting it into a 2d array char by char?
@abizardhofar3294
@abizardhofar3294 3 жыл бұрын
I want to read last row from the csv file and store in the array. How to do that? Can anyone help me out>
@emmanueloloruntola7436
@emmanueloloruntola7436 Жыл бұрын
How could I access this array in another class
@arturopresa6552
@arturopresa6552 2 жыл бұрын
Thanks so much for you explain what I needed to understand!
@twofacil
@twofacil 3 жыл бұрын
I will like to do the same but instead of read the file vertically i will like to read it horizontally.
HashMap Java Tutorial #50
11:42
Alex Lee
Рет қаралды 412 М.
Java File Input/Output - It's Way Easier Than You Think
8:18
Coding with John
Рет қаралды 461 М.
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 12 МЛН
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
Java read CSV File 📰
9:12
Bro Code
Рет қаралды 94 М.
Getters and Setters Java Tutorial #84
14:12
Alex Lee
Рет қаралды 499 М.
Abstract Class In Java Tutorial #79
8:55
Alex Lee
Рет қаралды 542 М.
Learn Java in 14 Minutes (seriously)
14:00
Alex Lee
Рет қаралды 4,8 МЛН
Object-Oriented Programming Java Tutorial (Java OOP) #71
14:07
Java Enum Tutorial #96
10:34
Alex Lee
Рет қаралды 159 М.
How to speak like the 1% elite
10:30
Joseph Tsar
Рет қаралды 13 М.
NEVER Memorize Vocabulary in a New Language - Use Artificial Immersion
10:04