My code performs separation of "**S12*T0*0832*B*86*N1C0~**S12*T0*0832*B*86*N1C0~"...Next i need to separate data between the "*" and utimately insert it into the database(ms-Access).i would like to recieve some code lines for that. Basically now the entire string i.e"**S12*T0*0832*B*86*N1C0" is being inserted into a column.i need to insert "S12" "T0" etc into separate columns. public static void main(String[] args) throws IOException { String token1 = "";// create token1 (deceleration only) List<String> temps = new ArrayList<String>();// Array Deceleration only @SuppressWarnings("resource") Scanner inFile1 = new Scanner(new File("2.txt")).useDelimiter("~");//reading text data separated by (~) while (inFile1.hasNext()) {// while loop token1 = inFile1.next();// find next line in inFile1 …

Member Avatar
Member Avatar
+0 forum 5

This piece of code is far from perfect, but it works! It produces a list of substrings (consisting of digits and letters) and their delimiters. If it is practicaly a sin to manipulate the index of a for loop, then I'm a sinner. If two delimiters follow each other, an empty string is produced between the two. If anyone can improve this, please do. Perhaps solutions with Regex or LINQ are possible. Or perhaps the great Ketsuekiame can again come up with a one liner? ;)

Member Avatar
Member Avatar
+0 forum 9

Hi All, i would need some advice from you guys from this forum to solve the reading of the CSV file that i had. for example, i have a file which consist of about 2000 records (below are the example of the records) 10/10/2013 10:25:09 AM,5.89,45,264.83,PTTTT 10/10/2013 10:25:13 AM,5.89,2000,11780.00, Some of the records are with the "PTTTT" and some dont. So how do i read the records for the part until 4th column and elimiate the PTTTT column ? Thanks

Member Avatar
Member Avatar
+0 forum 4

This is the block of data I have to work with: 5 5 5 6 5 8 9 5 6 8 good, very good, excellent, good 7 7 8 7 6 7 8 8 9 7 very good, Good, excellent, very good 8 7 6 7 8 7 5 6 8 7 GOOD, VERY GOOD, GOOD, AVERAGE 9 9 9 8 9 7 9 8 9 9 Excellent, very good, very good, excellent 7 8 8 7 8 7 8 9 6 8 very good, good, excellent, excellent 6 5 6 4 5 6 5 6 6 6 good, average, …

Member Avatar
Member Avatar
+0 forum 1

I have a tab delimited text file with text like this: Wed Jun 13 01:00:19 2012 | error | client xx.xxx.xxx.x | rdy 784 bsy 16 The pipe | signifies that the tab delimiter. I need to convert this into a CSV file using Java. I also need to split the "rdy 784 bsy 16" into two values. What is the best way of doing this?

Member Avatar
Member Avatar
+0 forum 1

Hi there, It's been a long time since I've used delimiters in the Scanner class in Java. If I wanted to have any numbers between an expression, such as xx/xx/xxxx or an infinite amount of numbers between them with just the forward slashes as delimiters, what would the syntax be? I came up with [CODE] s.useDelimiter(".*/.*/.*")[/CODE] And is this similar to C++ and Python? Also can't remember. D'oh! Sorry, and thanks for your help!

Member Avatar
Member Avatar
+0 forum 4

Hello. I am wondering how to split a string lets say char *a="raining apples training away" using a delimiter like "g a" and the result will be: rainin pples trainin way I tried using strstr but I got stuck. Any hints will be greatly appreciated. Thank you in advance!

Member Avatar
Member Avatar
+0 forum 3

Hello, I looking for a piece of code to chop a string into a array with 2 or more delimiters example: this is the text and I want to chop [!FIRST!] here and a bit later [!LAST!] here and if its posible (its not required) [!OPTIONAL!] chop it here and store this in a array like [code]array( [0] => "this is the text and I want to chop " [1] => "[!FIRST!]" [2] => " here and a bit later " [3] => "[!LAST!]" [4] => " here and if its posible (its not required) " [5] => "[!OPTIONAL!]" [6] …

Member Avatar
Member Avatar
+0 forum 4

I have a unit conversion program that needs to take in a float and 2 strings from standard input. My previous solution was: [CODE] float orig_quant; char *orig_name = (char*) malloc(MAX_CHARS); char *new_name = (char*) malloc(MAX_CHARS); fscanf(stdin, "%f %s %s", &orig_quant, orig_name, new_name); [/CODE] However, this only works if the input looks like [B]2.54 centimeters inches[/B] A requirement for the project is that the input looks like this [B]2.54, centimeters, inches[/B] I tried to change my fscanf to something like fscanf(stdin, "%f, %s, %s"...) but that didn't work. What is the easiest way I can get rid of those commas …

Member Avatar
Member Avatar
+0 forum 5

My text file is delimited (2 fields (text & numeric)). I'm trying to get the output into columnar format and include a count of the # of records following the columnar format. My text file is separated by commas. So far I can only read the text file. Here is [CODE]namespace ConsoleApplication5 { public class Class1 { static void Main(string[] args) { String line; { //Pass the file path and file name to the StreamReader constructor StreamReader sr = new StreamReader("data.txt"); //Read the first line of text line = sr.ReadLine(); //Continue to read until you reach end of file while …

Member Avatar
Member Avatar
+0 forum 14

I can not figure out why my code is reading in data to my vector in funny ways. I have added the input file and necesary class to test. It seems to be skipping values in the input file and also adding things to seperate places in the vector instead of one place like I intended. Any help would be much appreciated. [code=java] import java.util.*; import java.io.*; public class AddressBook { public static Vector<Contact> contacts = new Vector<Contact>(100, 10); //buildBook creates Contacts from the input txt file and adds them to a //vector. This vector is our Address Book public …

Member Avatar
Member Avatar
+0 forum 1

The End.