Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Code generation help

 
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a cv file which looks like this

I want to process the strings so that I get an output similar to this






Can someone suggest a simple String code to make "3D Objects " turn into "3dobjects"=>"3D Objects",

many thanks
[ November 07, 2007: Message edited by: Nikos Katsikanis ]
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... so what have you tried so far? What part of this is hard for you?
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there again

This is my code so far



in this part of the code it is failing to remove the quotes from the .csv file



also this code never evaluates to true



[ November 07, 2007: Message edited by: Nikos Katsikanis ]
[ November 07, 2007: Message edited by: Nikos Katsikanis ]
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it ok I've figured it out

I had to change

temp.replaceAll("\"", "");
to


temp = temp.replaceAll("\"", "");
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Guys I should have tried harder before posting. I just felt lazy when it come to working with Strings and was wanting one of yo guys to do the work. Please forgive me.


I created the working code and its here



From

 
Marshal
Posts: 22461
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't really get this. Why catch the NullPointerException? There is nothing there that could throw one. Not the creation of the file, the FileReader or the BufferedReader. Not the call to br.readLine(), data[count] or data.length. So what will throw it? Nothing, as far as I can see it.

The same goes for the ArrayIndexOutOfBoundsException. You make sure that data starts at 0, and you exit the loop as soon as it becomes too large for the array. So again, nothing could throw it.


Furthermore, you do know that br.readLine() will return null only when there is nothing more to be read? So if this occurs, the remainder of the array will be filled with "empty". If you want this, you could just as well break when it is null and use java.util.Arrays.fill(data, count, data.length, "empty"):
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob for knocking some sense into me there!!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic