Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csv_io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Bohn
csv_io
Commits
79f7bf42
Commit
79f7bf42
authored
5 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Changed write method's signature to accept any Iterable
parent
4821aa8f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/unl/cse/csv_io/CSVReaderWriter.java
+6
-5
6 additions, 5 deletions
src/main/java/edu/unl/cse/csv_io/CSVReaderWriter.java
with
6 additions
and
5 deletions
src/main/java/edu/unl/cse/csv_io/CSVReaderWriter.java
+
6
−
5
View file @
79f7bf42
...
@@ -67,6 +67,7 @@ public class CSVReaderWriter {
...
@@ -67,6 +67,7 @@ public class CSVReaderWriter {
}
}
/* LEGACY METHODS */
/* LEGACY METHODS */
@SuppressWarnings
(
"WeakerAccess"
)
public
static
Set
<
Map
<
String
,
String
>>
readCSV
(
String
filename
)
{
public
static
Set
<
Map
<
String
,
String
>>
readCSV
(
String
filename
)
{
return
readCSVasSet
(
filename
);
return
readCSVasSet
(
filename
);
}
}
...
@@ -85,7 +86,8 @@ public class CSVReaderWriter {
...
@@ -85,7 +86,8 @@ public class CSVReaderWriter {
// I'd like to replace this with something that uses openCSV, but it works, and openCSV doesn't seem to have
// I'd like to replace this with something that uses openCSV, but it works, and openCSV doesn't seem to have
// writers that take map<string,string>
// writers that take map<string,string>
public
static
boolean
writeCSV
(
String
filename
,
Set
<
Map
<
String
,
String
>>
data
)
{
@SuppressWarnings
(
"WeakerAccess"
)
public
static
boolean
writeCSV
(
String
filename
,
Iterable
<
Map
<
String
,
String
>>
data
)
{
boolean
wroteFile
=
true
;
boolean
wroteFile
=
true
;
ClassLoader
classLoader
=
CSVReaderWriter
.
class
.
getClassLoader
();
ClassLoader
classLoader
=
CSVReaderWriter
.
class
.
getClassLoader
();
URL
resource
=
classLoader
.
getResource
(
"csv/"
+
filename
);
URL
resource
=
classLoader
.
getResource
(
"csv/"
+
filename
);
...
@@ -145,7 +147,7 @@ public class CSVReaderWriter {
...
@@ -145,7 +147,7 @@ public class CSVReaderWriter {
}
}
*/
*/
static
void
placeCSVonStream
(
Set
<
Map
<
String
,
String
>>
data
,
OutputStream
outputStream
)
{
static
void
placeCSVonStream
(
Iterable
<
Map
<
String
,
String
>>
data
,
OutputStream
outputStream
)
{
PrintStream
writer
=
new
PrintStream
(
outputStream
);
PrintStream
writer
=
new
PrintStream
(
outputStream
);
Set
<
String
>
fieldNames
=
null
;
Set
<
String
>
fieldNames
=
null
;
int
number_of_fields
=
0
;
int
number_of_fields
=
0
;
...
@@ -167,11 +169,10 @@ public class CSVReaderWriter {
...
@@ -167,11 +169,10 @@ public class CSVReaderWriter {
}
}
}
}
}
}
/*
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Set
<
Map
<
String
,
String
>>
demo
=
readCSV
(
"demo.csv"
);
Set
<
Map
<
String
,
String
>>
demo
=
readCSV
(
"demo.csv"
);
boolean
success
=
writeCSV
(
"out.csv"
,
demo
);
boolean
success
=
writeCSV
(
"out.csv"
,
demo
);
System
.
out
.
println
(
success
?
"Wrote file!"
:
"Didn't write file"
);
System
.
out
.
println
(
success
?
"Wrote file!"
:
"Didn't write file"
);
}
}
*/
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment