Skip to content

Arson90/csv-reader-writer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSV-Reader-Writer

Description

Writing a CSV file, reading a CSV file and writing data from CSV to txt file in Java using OpenCSV. Additionally, the program counts the sum and average data.

Overview

Introducing

Step by step

  1. This method is responsible for writing some example data to a CSV file.
  • First we create an instance of CSVWriter by passing FileWriter object as a parameter and example file name as s parameter.
  • Adding examples values and saving to salaries.scv file.
  • Default Separated Value is a comma → CSVWriter.DEFAULT_SEPARATOR

writingCSV

  1. This method is responsible for reading data from the salaries.csv file.
  • After reading the data the count method is called by passing data as a parameter.

readingCSV

  1. This method is responsible for counting a sum and an average values from the salaries.csv file.
  • First we count a sum and an average row by row.
  • After counting, the displayResults is called by passing two parameters.

count

  1. This method is responsible for displaying data in console in specific format.
  • After processing the data, the writingTXTFile method is called by passing rows as a parameter.

displayResult

  1. This method is responsible for writing data from salaries.csv to salariesStatistics.txt.
  • First we create an instance of FileWriter by passing file name as a parameter.
  • Saving data to to salariesStatistics.txt

writingTXT

Prerequisite

  • Install IntelliJ IDEA
  • Install JDK (Java Development Kit)
  • OpenCSV → is a CSV parser library for Java. Dependency responsible for this library was added to pom.xml file.

maven

Installing Tools

Windows

  • Download and install IntelliJ IDEA (community version is free)
  • Download and install JDK
  • Set the JDK path on Windows

Linux

Follow this link to see the instruction about installing necessery tools on Linux

Running Examples

  • Download the zip or clone the Git repository
  • Unzip the zip file to you projects directory
  • Open IntelliJ
    • File → Open → Navigate to the folder where you unzipped the zip
    • Select the right project
  • If you want to clone the repository you need to:
  • Copy the project link
  • Open IntelliJ
    • File → New → Project from Version Control
    • Paste the link and click Clone
  • Right Click on the file and Run as Java Application

Troubleshooting

Probably after openning the project you will have to set the JDK in IntelliJ IDEA.

  • Project structure → Project settings → Project → SDK → choose the right JDK version (1.8 or newer)

Useful links

About

Writing and reading CSV file with data

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages