How to put 58 columns of data into an array in one shot?
I have a set of data with 58 columns and 5000 rows. However, I need to find offset for all the elements in this 5000x58 set of data. Is there an easier way to put all the data (offset) into an array in one shot other than using build array function? This is because if I use the build array function, I will need to separate all the data into 58 columns by indexing them. This is too time consuming.
Thanks for the suggestion! Have a good day!
VanessaWen wrote:
I have a set of data with 58 columns and 5000 rows. However, I need to find offset for all the elements in this 5000x58 set of data. Is there an easier way to put all the data (offset) into an array in one shot other than using build array function? This is because if I use the build array function, I will need to separate all the data into 58 columns by indexing them. This is too time consuming.
You need to explain in much more detail, because your problem is not clear.
Is this a 2D array with 58 columns and 5000 rows?
What is your definition of "offset"?
Where does the offset value come from?
Is "offset" it the same for each row (or column) or does it depend on the data?
What is the definition of "one shot"?
Why would you need to seperate all the data into columns in order to use build array?
It it "too time consuming" to write the program or is the execution slower than expected?
Is the final output a 1D or 2D array or something else?
Please attach a VI containing a small 2D array diagram constant with typical data, then show us what kind of output you would expect after applying the described operation.
LabVIEW Champion . Do more with less code and in less time .
Similar Messages
-
How do I put and sort string data into an array?
I have a txt file that has the following sample data:
Sample.txt----
Jones Bill 12,500 Salesperson
Adams Frank 34,980 Manager
Adams John 23,000 Salesperson
Thompson Joe 59,500 Trainee
I need to incorporate each line of data into an individual array element, while using a user-defined method
(ex. setAllValues(String last, String first, String salary, String job)
How do I loop the data into the array to be displayed and what is the best way to do sorts on this sample data. Any code or clues would be super helpful.
SanctosIf you set up an array of Strings you can use the java.util.Arrays.sort() method to sort it. If you need to sort arbitrary Objects (i.e. your 3 strings as a whole entity) your 3-way object will have to either implement Comparable or you could write a Comparitor class to do the ordering. Not much to it, though.
Dom. -
How to put data into a array element in the BPEL
Hi,
I have a element in the WSDL which is of type Array. (i.e accepts unlimited data for the same element). How should i put a data into a array in the BPEL.
Example:
The below Example gives u an idea about wht iam asking:pasting a piece of my requirement:
<s:element minOccurs="0" maxOccurs="1" name="parameters" type="tns:ArrayOfCSParameters" />
<s:complexType name="ArrayOfCSParameters">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded"
name="CSParameters" nillable="true" type="tns:CSParameters" />
</s:sequence>
</s:complexType>
<s:complexType name="CSParameters">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="RevenueItem" type="tns:RevenueItem" />
<s:element minOccurs="0" maxOccurs="1" name="AccountURIs" type="tns:ArrayOfString" />
<s:element minOccurs="0" maxOccurs="1" name="GroupURIs" type="tns:ArrayOfString" />
<s:element minOccurs="1" maxOccurs="1" name="Percentage" nillable="true" type="s:decimal" />
</s:sequence>
<s:attribute name="Version" type="s:decimal" use="required" />
<s:attribute name="URI" type="s:string" />
</s:complexType>
Any suggestion is appreciated.
Regards
pavanYou have 2 options i guess.
Use the transformation and the for-each to construct the array-list
or like Richard said, use a loop in bpel, assign in the loop an variable of element type="CSParameters" and append this variable to your variable with accepts the arraylist. -
How to put 2nd column into 1st column in excel
Hello,
I have a question how to put 2nd column into 1st column in excel. Thank you.
Solved!
Go to Solution.Why the 1 iteration for loops?
Why the two Index Arrays? It is just trying to fix the problem created by the For Loops on the original 1-D arrays.
Both of those things are creating 2-D arrays that are complicating things and can be eliminated.
You can take your 2 1-D arrays, use Build Array and right click to set "Concatenate Inputs".
If you do have a 2-D array, you can use Reshape Array to make it a 1 column by N row 2-D array. -
Need help in putting data into 2d array
My input file :
1 , 2 , 1
2 , 2 , 1
3 , 3 , 1
4 , 2 , 2
2 , 3 , 2I'm stuck at:
while( reader.readLine() != null){
String Matrix[] = line.split(",");
}Means I only can read how many lines there. For 2d array, Matrix[i][j], is that when I count the line, the number of count will be the 'i'? How about 'j'? Am I need to count i and j before put the data into 2d array?
Do correct me if something wrong in:
while( reader.readLine() != null){
String Matrix[] = line.split(",");
} Thank you.gtt0402 wrote:
while( reader.readLine() != null){
String Matrix[] = line.split(",");
How about:
ArrayList<String[]> rows = new ArrayList<String[]>();
while((line = reader.readLine()) != null) {
rows.add(line.split(","));
}After the loop you have a list full of String arrays and you can convert it to a 2D String array if you wish. -
How to create a variance on data that exists iIn only one database column
How to create a variance on data that exists iIn only one database column?
I'm trying to create a calculation to show the difference between the budgets for two different years in a Discoverer crosstab query.
I'm using the lag function to repeat the value of a column for the current year and the year before.Lag and lead seems to be the only choice and they work excellent. Checkout the new 10g Database features. There is new SQL modal clause which might give additional and powerful analytics but in this case lag and lead should be sufficient.
regards
http://www.infocaptor.com/workbook-dump.php -
How to get the plsql table data into output cursor
Hi,
Could anybody please help me.
Below is an example of the scenario..
CREATE OR REPLACE PACKAGE chck IS
PROCEDURE getdata(dept_no IN VARCHAR2,oc_result_cursor OUT sys_REFCURSOR);
TYPE get_rec is record (ename varchar2(20),
eno number(12));
TYPE t_recs IS TABLE OF get_rec INDEX BY BINARY_INTEGER;
emp_tab t_recs;
END chck;
CREATE OR REPLACE PACKAGE BODY chck AS
PROCEDURE getdata(dept_no IN VARCHAR2,oc_result_cursor OUT sys_REFCURSOR)
is
BEGIN
select ename, eno
bulk collect into emp_tab
from emp;
open oc_result_cursor for select * from table(emp_tab); -- I believe something is wrong here ....
END;
END chck;
the above package is giving me an error:
LINE/COL ERROR
10/29 PL/SQL: SQL Statement ignored
10/43 PL/SQL: ORA-22905: cannot access rows from a non-nested table
item
let me know what needs to be changed
Thanks
Manjumanjukn wrote:
once i get the data into a plsql table, how to get this plsql table data into the cursor?There is no such thing as a PL/SQL table - it is an array.
It is nothing at all like a table. It cannot be indexed, partitioned, cluster, etc. It does not exist in the SQL engine as an object that can be referenced. It resides in expensive PGA memory and needs to be copied (lock, stock and barrel) to the SQL engine as a bind variable.
It is an extremely primitive structure - and should never be confused as being just like a table.
Its use in SQL statements is also an exception to the rule. Sound and valid technical reasons need to justify why one want to push a PL/SQL array to the SQL engine to run SELECT 's against it. -
How to store the flat file data into custom table?
Hi,
Iam working on inbound interface.Can any one tell me how to store the flat file data into custom table?what is the procedure?
Regards,
SujanHie
u can use function
F4_FILENAME
to pick the file from front-end or location.
then use function
WS_UPLOAD
to upload into
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME' "Function to pick file
EXPORTING
field_name = 'p_file' "file
IMPORTING
file_name = p_file. "file
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file1
TABLES
data_tab = it_line
*then loop at it_line splitting it into the fields of your custom table.
loop at it_line.
split itline at ',' into
itab-name
itab-surname.
endloop.
then u can insert the values into yo table from the itab work area.
regards
Isaac Prince -
How to put the new developed Requirement into an output type procedure...
Hi,
If we developed an new Requirement for an output type, how to put this new requirement number into the output type procedure???
for example: RV61B912
The requirement number is 912.
Thanksany helps?
Thanks -
How to aggregate a column based date column (for weekly single row)?
How to aggregate a column based date column (for weekly single row)?
Hi,
Consider the below statement for daily bases which is ok
SELECT ID, DATE, SUM(AMOUNT) FROM TABLE_NAME GROUP BY ID, DATE ORDER BY ID, DATE
The same like the above statement, I want output on weekly, fortnightly, and monthly bases, How to do this? Need your help... -
How can I read the trace data into LabVIEW for E5071B
HI
I am setting up the measurement using vector network analyzer (VNA) E5071B controlled by NI 488.2. How can I read the trace data into LabVIEW and display on the graph? If anyone having an idea or know well about this process please give me the suggestion, I will much appreciate it.
Many ThanksYou want to start with the driver
In case you do not know it, you can do the driver search in LabVIEW from Tools>Instrumentation>Find Instrument Drivers. You might also want to bookmark the Instrument Driver Network for information on what a driver is and how to use it. -
(Urgent help needed) how to read txt file and store the data into 2D-array?
Hi, I have a GUI which allow to choose file from the file chooser, and when "Read file" button is pressed, I want to show the array data into the textarea.
The sample data is like this followed:
-0.0007 -0.0061 0.0006
-0.0002 0.0203 0.0066
0 0.2317 0.008
0.0017 0.5957 0.0008
0.0024 1.071 0.0029
0.0439 1.4873 -0.0003
I want my program to scan through and store these data into 2D array.
However for some reason, my source code issues errors, and I don't know what's wrong with it, seems to have a problem in StringTokenizer though. Can anybody help me?
Thanks in advance.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.StringTokenizer;
public class FileReduction1 extends JFrame implements ActionListener{
// GUI features
private BufferedReader fileInput;
private JTextArea textArea;
private JButton openButton, readButton,processButton,saveButton;
private JTextField textfield;
private JPanel pnlfile;
private JPanel buttonpnl;
private JPanel buttonbar;
// Other fields
private File fileName;
private String[][] data;
private int numLines;
public FileReduction1(String s) {
super(s);
// Content pane
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
// Open button Panel
pnlfile=new JPanel(new BorderLayout());
textfield=new JTextField();
openButton = new JButton("Open File");
openButton.addActionListener(this);
pnlfile.add(openButton,BorderLayout.WEST);
pnlfile.add(textfield,BorderLayout.CENTER);
readButton = new JButton("Read File");
readButton.addActionListener(this);
readButton.setEnabled(false);
pnlfile.add(readButton,BorderLayout.EAST);
cp.add(pnlfile, BorderLayout.NORTH);
// Text area
textArea = new JTextArea(10, 100);
cp.add(new JScrollPane(textArea),BorderLayout.CENTER);
processButton = new JButton("Process");
//processButton.addActionListener(this);
saveButton=new JButton("Save into");
//saveButton.addActionListener(this);
buttonbar=new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonpnl=new JPanel(new GridLayout(1,0));
buttonpnl.add(processButton);
buttonpnl.add(saveButton);
buttonbar.add(buttonpnl);
cp.add(buttonbar,BorderLayout.SOUTH);
/* ACTION PERFORMED */
public void actionPerformed(ActionEvent event) {
if (event.getActionCommand().equals("Open File")) getFileName();
if (event.getActionCommand().equals("Read File")) readFile();
/* OPEN THE FILE */
private void getFileName() {
// Display file dialog so user can select file to open
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int result = fileChooser.showOpenDialog(this);
// If cancel button selected return
if (result == JFileChooser.CANCEL_OPTION) return;
if (result == JFileChooser.APPROVE_OPTION)
fileName = fileChooser.getSelectedFile();
textfield.setText(fileName.getName());
if (checkFileName()) {
openButton.setEnabled(false);
readButton.setEnabled(true);
// Obtain selected file
/* READ FILE */
private void readFile() {
// Disable read button
readButton.setEnabled(false);
// Dimension data structure
getNumberOfLines();
data = new String[numLines][];
// Read file
readTheFile();
// Output to text area
textArea.setText(data[0][0] + "\n");
for(int index=0;index < data.length;index++)
for(int j=1;j<data[index].length;j++)
textArea.append(data[index][j] + "\n");
// Rnable open button
openButton.setEnabled(true);
/* GET NUMBER OF LINES */
/* Get number of lines in file and prepare data structure. */
private void getNumberOfLines() {
int counter = 0;
// Open the file
openFile();
// Loop through file incrementing counter
try {
String line = fileInput.readLine();
while (line != null) {
counter++;
System.out.println("(" + counter + ") " + line);
line = fileInput.readLine();
numLines = counter;
closeFile();
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error reading File",
"Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile();
System.exit(1);
/* READ FILE */
private void readTheFile() {
// Open the file
int row=0;
int col=0;
openFile();
System.out.println("Read the file");
// Loop through file incrementing counter
try {
String line = fileInput.readLine();
while (line != null)
StringTokenizer st=new StringTokenizer(line);
while(st.hasMoreTokens())
data[row][col]=st.nextToken();
System.out.println(data[row][col]);
col++;
row++;
closeFile();
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error reading File",
"Error 5: ",JOptionPane.ERROR_MESSAGE);
closeFile();
System.exit(1);
/* CHECK FILE NAME */
/* Return flase if selected file is a directory, access is denied or is
not a file name. */
private boolean checkFileName() {
if (fileName.exists()) {
if (fileName.canRead()) {
if (fileName.isFile()) return(true);
else JOptionPane.showMessageDialog(null,
"ERROR 3: File is a directory");
else JOptionPane.showMessageDialog(null,
"ERROR 2: Access denied");
else JOptionPane.showMessageDialog(null,
"ERROR 1: No such file!");
// Return
return(false);
/* FILE HANDLING UTILITIES */
/* OPEN FILE */
private void openFile() {
try {
// Open file
FileReader file = new FileReader(fileName);
fileInput = new BufferedReader(file);
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Opening File",
"Error 4: ",JOptionPane.ERROR_MESSAGE);
System.out.println("File opened");
/* CLOSE FILE */
private void closeFile() {
if (fileInput != null) {
try {
fileInput.close();
catch (IOException ioException) {
JOptionPane.showMessageDialog(this,"Error Opening File",
"Error 4: ",JOptionPane.ERROR_MESSAGE);
System.out.println("File closed");
/* MAIN METHOD */
/* MAIN METHOD */
public static void main(String[] args) throws IOException {
// Create instance of class FileChooser
FileReduction1 newFile = new FileReduction1("File Reduction Program");
// Make window vissible
newFile.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
newFile.setSize(500,400);
newFile.setVisible(true);
Java.lang.NullpointException
at FileReductoin1.readTheFile <FileReduction1.java :172>
at FileReductoin1.readFile <FileReduction1.java :110>
at FileReductoin1.actionPerformed <FileReduction1.java :71>
.1) Next time use the CODE tags. this is way too much unreadable crap.
2) The problem is your String[][] data.... the only place I see you do anything approching initializing it is
data = new String[numLines][];I think you want to do this..
data = new String[numLines][3];anyway that's why it's blowing up on the line
data[row][col]=st.nextToken(); -
How do you store parsed XML data in an array
Hi, i am trying to complete a small program which implements the SAX parser to parse an XML file. My problem is that i am writing a custom class to store the parsed data into an array, and then make the array available to the main program via a simple method which returns the array. I know this must be very simple to do, but i seem to have developed a mental block with this part of the program. I can parse the data and print all the elements to the screen, but i just cant figure out how to store all the data elements into the array. I will post the class which is supposed to do this, and ask anyone out there if they know what i'm doing wrong, and also, if there is a more effeicient way of achieving this ( i expect there definitely is!! but i have never used the SAX parser before and am getting confused by the API docs on it!!) Any help very much appreciated.
Here is my attempt at coding the class to handle the parsed XML data
class Sink extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ContentHandler{
Customer[] customers = new Customer[20];
int count = 1;
int x = 0;
int tagCount = 0;
String name;
String custID;
String username;
String address;
String phoneNum;
public void startElement(String uri, String localName, String rawName, final org.xml.sax.Attributes attributes)throws org.xml.sax.SAXException{
//count the number of <name> tags in the XML file
if(rawName.equals("name")){
tagCount++;
public void characters(char[] ch, int start, int len){
//get the current string
String text = new String(ch, start, len);
String text1 = text.trim();
//there are 5 elements for each customer found in the XML file so when the count reaches 6
// i reset this to 1
if(count == 6){
count = count - 5;
if(text1.length()>0 && count == 1){
name = text1;
System.out.println(name);
}else{
if(text1.length()>0 && count == 2){
custID = text1;
System.out.println(custID);
}else{
if(text1.length()>0 && count == 3){
username = text1;
System.out.println(username);
}else{
if(text1.length()>0 && count == 4){
address = text1;
System.out.println(address);
}else{
if(text1.length()>0 && count == 5){
phoneNum = text1;
System.out.println(phoneNum);
//add data to the customer array
customers[x] = new Customer(name, custID, username, address, phoneNum);
// increment the array index counter
x = x+1;
}//end of if
}//end else
}//end else
}//end else
}//end else
}//end of characters method
public void endDocument(){
System.out.println("There are " + tagCount +
" <name> elements.");
}//end of class Sink
Before the end of this class i also need to make the array available to the calling program!!
Any help would be much appreciated
Thanks
IainOk, yer going about this all the wrong way. You shouldn't have to maintain a count of all the elements. Basically you are locking yourself into the XML tags not only all being there but are assuming they are all in the same order. What you should do is in your characters() method, put all of the characters into a string buffer. Then, in endElement() (which you dont use btw, you should) you grab the information that is in the string buffer and store it into your Customer object depending on what the tagName is.
Also, you should probably use a List to store all the Customer objects and not an single array, it's more dynamic and you arent locked into a set number of Customers.
I wont do it all for you, but I'll give you a good outline to use.
public class CustomerHandler extends DefaultHandler {
private java.util.List customerList; // List of Customer objects
private java.util.StringBuffer buf; // StringBuffer to store the string of characters between the start and end tags
private Customer customer; // Customer object that is initialized with each entry.
public CustomerHandler() {
customerList = new java.util.ArrayList(); // Initialize the List
buf = new java.util.StringBuffer(); // Initialize the string buffer
// Make your customer list available to other classes
public java.util.List getCustomerList() {
return customerList;
public void startElement(String nsURI, String sName, String tagName, Attributes attributes) throws SAXException {
// Clear the String Buffer
// If the tagName is "Customer" then create a new Customer object
public void characters(char[] ch, int start, int length) {
// append the characters into the string buffer
public void endElement(String nsURI, String sName, String tagName) throws SAXException {
// If the tagName is "Customer" add your customer object to the List
// Place the data from the String Buffer into a String
// Depending on the tagName, call the appropriate set method on your customer object
} -
How to get input from keyboard scanner into an array
This is probably a very basic question but I'm very new to java..
My task is to reverse a string of five digits which have been entered using keyboard scanner.
E.g. - Entered number - 45896
Output - 69854
I used the StringBuffer(inputString).reverse() command for this, but i need a more basic method to do this.
I thought of defining an array of 5
int[] array = new int [5];
and then using,
Scanner scan = new Scanner(System.in);
to enter the numbers. But I can't figure out how to get the five input numbers into the array.
If I can do this I can print the array in reverse order to get my result.
Any other simple method is also welcome.Hey thanks for the quick reply,
But how can I assign the whole five digit number into the array at once without asking to enter numbers separately?
E.g. - if entered number is 65789
Assign digits into positions,
anArray [0] = 6;
anArray [1] = 5;
anArray [2] = 7;
anArray [3] = 8;
anArray [4] = 9;
I'm really sorry but I am very new to the whole subject. -
How to Automate to Add a Role for 250+ Users in One Shot ?
Hi all,
How can I add a Role 'X' for 250+ User in one shot. I could go to SU01 for each User and add a Role 'X' manually, but it will take at least more than two hours. Is there any automation to accomplish this task, PLEASE ?
Thanks.Look at the How To paper on maintaining authorizations through flat file...
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1d8ea990-0201-0010-43b3-d13b83e2bf20">How to maintain authorizations through flat file</a>
Hope this helps.
Maybe you are looking for
-
Exchange 2007 to Exchange 2010 Cross Forest
Hi We have a scenario where we have an Exchange 2007 organization (Org A - Source) and a separate Exchange 2010 organization (Org B - Target). Both the organizations (AD Forests) have two way trusts between them. We want to have our Exchange 2007 use
-
Computer Stuttering Repeatedly
Every 10 seconds or so my system freezes then starts moving again. This is quite annoying. I've ran Disk Utility and fixed permissions, ran Apple Hardware Test and no problems were found. Please help!
-
Facetime reverted back to older version after Lion install.
I purchased Factime from App Store and after upgrading to Lion OS, it has been reverted back to Version 1.1. App store is asking me to purchase it back again to upgrade it to V 1.2. Does it mean for every bug fix and version upgrade i have to pay app
-
Hello Gurus, we just migrated to SAP BI 7.0. We didn´t change the way the Web Reports are called through a menu object, that was developed with WAD 3.5. As there is a new version of Web Analyzer available, can it be called just with the right templat
-
Dear Fnds, My requirement is, Iam displaying output data in ALV. in the output ALV i have 10 rows. in the 10 rows if i select 5 rows(any rows), Example 3,7,1,2,5, Do we have any function module or class to determine the selected row sequence (which o