473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

populate a rectangular array from a CSV file

4
hllo Java Professionals!
I need help populating an array with a CSV or tab seperated file
I have a file called Data.txt formatted as shown below. The number of columns or rows can vary in size depending on the .txt file i tell the method to use.

1.5 88 106 141 177
2 157 189 251 314
2.5 245 295 393 491
3.25 415 498 664 830
4 628 754 1005 1257
5 982 1178 1571 1964
6 1414 1696 2262 2827
7 1924 2309 3079 3849
8 2513 3016 4021 5027
10 3927 4712 6283 7854
12 5655 6786 9048 11310
14 7697 9236 12315 15394
16 10053 12064 16085 20106
18 12723 15268 20358 25447
20 15708 18850 25133 31416


double[][] data = new Double [15] [14];
data [0][0] = 1.5
data [0][1] = 88
data [1][0] = 2 and so on.

each column represents calculated values at different line pressures. say line pressure of 50 was used for the second column and line presssure of 100 was used for the third column... i want to pass the line pressure double and the value to the method and have it search the correct line pressure column until it finds the first double larger than the value and report the value in the first column. So say I pass the double 50 and double 1000 to the method it would return 6

Any help would be greatly appreciated
Jun 16 '12 #1
2 2002
Dilley
4
Just help populating the array with the text file would be a great help!
Jun 16 '12 #2
Dilley
4
So far this is what I have but I am getting all kinds of errors. Can anyone help me sort this out?


Expand|Select|Wrap|Line Numbers
  1.  
  2.        double[][] numbers = new double[15][14];
  3.  
  4.         try 
  5.         {
  6.             br = new BufferedReader(new FileReader("Cylinder Pressure Chart.txt"));
  7.             String line = null;
  8.  
  9.         while ((line = br.readLine()) != null) 
  10.         {
  11.  
  12.             for(int i=0; i<=15; i++)
  13.             {
  14.                 for(int j=0; j<=14; j++)
  15.                 {
  16.                     numbers[i][j] = line.split("\t");
  17.                 }
  18.             }
  19.  
Jun 16 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mike | last post by:
I'm fairly green with javascript, and have been looking everywhere for an example of how to load data from a mysql db into javascript arrays. For a little background on what I'm trying to do, any...
2
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to...
5
by: Daniel Walzenbach | last post by:
Hi, I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed). The preferable solution would be...
1
by: almurph | last post by:
Hi everyone, I have a "SqlDataReader" that I know has 2 columns in it with around 361 rows of data like: columnA columnB value1 value3 value1 value4
2
by: Thirsty Traveler | last post by:
I have an application that will be accessing an array of ports obtained from a config file. What would be the best way to do populate the array if the config file has, say, the following format: ...
2
by: jampoole | last post by:
Hi all, I'm working in the C language. I've been stuck for 2 weeks trying to figure out how in the world to populate arrays after reading in an input FILE. the input file has numbers and ...
12
by: holla | last post by:
how do u populate an array
3
by: Guilherme Grillo | last post by:
Hi Friends, How can I populate an Array with the information of an Table in SQL? Thanks... and sorry my english... Grillo
1
by: DavidPr | last post by:
I have a website that requires a visitor to register in order to make a post. I have one or two users that are violating the terms and every day I'm having to delete them. They just re-register,...
0
by: stumpednewbie | last post by:
my code (what I think I want): for (lv=0;lv<20;lv++) { if (kbhit())//look for keypress kp=getch();//assign keypress to variable "kp" SD=(kp);//populate array with wanted digits }
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.