Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Program design  RSS feed

 
Robert Sta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to develope an program which checks a file for several things.
The file which should be checked is an CSV file, delimiter is semicolon.
The program should contain following features / functions:



My questions is how is the best way to design the program.
How to inport the file and do the checks for each column?
Should I use an database to store the values and compare or use Strings?
How about the other features? Any suggestion how to implement the features above?
 
Junilu Lacar
Sheriff
Posts: 11146
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert Sta wrote:
The file which should be checked is an CSV file, delimiter is semicolon.

That's contradictory. CSV is a de facto standard and has well-established formatting rules. The file you're processing is either CSV, in which case, delimiters are double quotes or it's not CSV and has semicolons as delimiters. Which is it? If delimiters really are semicolons, then you shouldn't say it's a CSV file; Delimiter-separated values would probably be a better term for it.
 
Junilu Lacar
Sheriff
Posts: 11146
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the very least, you want to have good Separation of Concerns. Assign different concerns to different parts of your program and have each part do one and only one thing well (Single Responsibility Principle)
 
Robert Sta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:
Robert Sta wrote:
The file which should be checked is an CSV file, delimiter is semicolon.

That's contradictory. CSV is a de facto standard and has well-established formatting rules. The file you're processing is either CSV, in which case, delimiters are double quotes or it's not CSV and has semicolons as delimiters. Which is it? If delimiters really are semicolons, then you shouldn't say it's a CSV file; Delimiter-separated values would probably be a better term for it.



Hey Junilu,

thanks for your quick response.
I'm not sure if I understand you right. How ever, the following example should show what I meant:

Example of an analogous European CSV/DSV file (where the decimal separator is a comma and the value separator is a semicolon):

Year;Make;Model;Length
1997;Ford;E350;2,34
2000;Mercury;Cougar;2,38


 
Junilu Lacar
Sheriff
Posts: 11146
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is nitpicky but CSV stands for Comma Separated Values -- if the delimiters value separators are semicolons, then it's not CSV. That's all I was pointing out.
 
Liutauras Vilda
Marshal
Posts: 4641
318
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are these all your requirements you putted as a comment? Is it homework?
 
Claudiu Chelemen
Ranch Hand
Posts: 75
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:I know this is nitpicky but CSV stands for Comma Separated Values -- if the delimiters value separators are semicolons, then it's not CSV. That's all I was pointing out.


It's actually pretty common that CSV files would have a different separator, and most of the times it would be semicolon. Eg. on windows platforms, it gets the separator from the regional settings.
So I wouldn't say it's all that wrong.

As for the program, do you have anything so far ?

Claudiu
 
Stephan van Hulst
Saloon Keeper
Posts: 7808
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claudiu Chelemen wrote:It's actually pretty common that CSV files would have a different separator, and most of the times it would be semicolon. Eg. on windows platforms, it gets the separator from the regional settings.
So I wouldn't say it's all that wrong.


Then they're not CSV files. It's like saying I'm going to store something as an XML file, but instead of using text, I'm going to store pictures of my notepad.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Then they're not CSV files. It's like saying I'm going to store something as an XML file, but instead of using text...

Well, to give Claudiu his due, the Wiki page does say that " In popular usage ... the term CSV may denote some closely related delimiter-separated formats".

@Robert: Parsing CSV (or DSV) files is not as simple as you might think, because a "field" might contain the delimiter you use (which is just one of the reasons I prefer TAB-separation) - and a fair bit of the standard is taken up in describing how to encode (and parse) those sorts of situations.

There are, however, several open-source libraries around for doing it, so I suggest you take a spin on Google. Alternatively, someone here may be able to suggest a good one.

HIH

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!