From the course: Data Science for Java Developers
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Converting strings to data objects - Java Tutorial
From the course: Data Science for Java Developers
Converting strings to data objects
- All right. So now let's actually implement this parse person static method here. So what we're basically going to do this string is going to be one of the lines that we loaded from here. So if you take a look at these here it's basically a comma-separated string. And what we're going to want to do is split this string into basically a list of strings. And then we're basically just going to pull the individual attributes out based on their position in the string, based on their index that is, so what we're going to want to do now is assuming we have the data string which is going to be a line of our text file. We're going to start off by saying List String fields = dataString .split and we're going to split it by a comma and we're going to need to do new Array List Arrays.asList since this returns an array of strings instead of a list like we want. And now that we have our array list of fields which is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Reducing file size5m 20s
-
Loading data from text files3m 29s
-
Creating a person data class3m 56s
-
Converting strings to data objects5m 39s
-
Loading tab-separated files9m 20s
-
Loading CSVs5m 21s
-
Converting CSVs to data objects7m 4s
-
Challenge: Manipulating data2m 1s
-
Solution: Manipulating data3m 37s
-
-
-
-
-