String to array convertion problem
Hi,
I am reading this from url which returns js array. But when i m trying to covert int to array i stuck.
string str="[{"CompanyCode":"17023928","LastTradedPrice":"15,878.68","Volume":
"0","PercentageDiff":"1.35","FiftyTwoWeekHigh":"21,206.77","FiftyTwoWeekLow":"12
,316.10","LastTradedTime":"01 Sep,11:50:01","ChangePercent":"1.35","Change":"212
.04","MarketCap":"0.00","High":"15,046.43","Low":"14,733.59","PrevClose":"15,666
.64"},{"CompanyCode":"16010003","LastTradedPrice":"384.00","Volume":"38,424","Pe
rcentageDiff":"2.89","FiftyTwoWeekHigh":"592.90","FiftyTwoWeekLow":"110.00","Las
tTradedTime":"01 Sep,11:50:00","ChangePercent":"2.89","Change":"10.80","MarketCa
p":"1,482.24","High":"386.50","Low":"376.70","PrevClose":"373.20"},{"CompanyCode
":"15210029","LastTradedPrice":"142.90","Volume":"270,727","PercentageDiff":"-0.
10","FiftyTwoWeekHigh":"183.50","FiftyTwoWeekLow":"45.60","LastTradedTime":"01 S
ep,11:50:04","ChangePercent":"-0.10","Change":"-0.15","MarketCap":"26,017.80","H
igh":"145.05","Low":"142.70","PrevClose":"143.05"}]";
I tried this but this is not working bc value are coma fromated.
public void str2Array(String str)
str=str.substring(1,str.length()-1);
//String[] st=str.split("{");
//System.out.println("ltp "+st[0]);
str=removeChar(str,'"');
System.out.println("after remove"+str);
StringTokenizer st = new StringTokenizer(str,"{");
Vector ltp=new Vector();
Vector chgPer=new Vector();
while (st.hasMoreTokens())
String tmp=st.nextToken();
System.out.println("tmp "+tmp);
String[] res=tmp.split(",");
//ltp.add(res[3]);
//chgPer.add(res[3]);
//System.out.println("\nchg "+res[6]+" chg% "+res[7]+" ltp "+res[2]+" val "+res[3]);
for(int i=0;i<res.length;i++)
System.out.println("\n"+"ic "+i+" val "+res);
if(
{code}
plz help me out.
Thanks
I think using split() is wrong and that you need something more like
final String str = "[{\"CompanyCode\":\"17023928\",\"LastTradedPrice\":\"15,878.68\",\"Volume\":\"0\",\"PercentageDiff\":\"1.35\",\"FiftyTwoWeekHigh\":\"21,206.77\",\"FiftyTwoWeekLow\":\"12,316.10\",\"LastTradedTime\":\"01 Sep,11:50:01\",\"ChangePercent\":\"1.35\",\"Change\":\"212.04\",\"MarketCap\":\"0.00\",\"High\":\"15,046.43\",\"Low\":\"14,733.59\",\"PrevClose\":\"15,666.64\"},{\"CompanyCode\":\"16010003\",\"LastTradedPrice\":\"384.00\",\"Volume\":\"38,424\",\"PercentageDiff\":\"2.89\",\"FiftyTwoWeekHigh\":\"592.90\",\"FiftyTwoWeekLow\":\"110.00\",\"LastTradedTime\":\"01 Sep,11:50:00\",\"ChangePercent\":\"2.89\",\"Change\":\"10.80\",\"MarketCap\":\"1,482.24\",\"High\":\"386.50\",\"Low\":\"376.70\",\"PrevClose\":\"373.20\"},{\"CompanyCode\":\"15210029\",\"LastTradedPrice\":\"142.90\",\"Volume\":\"270,727\",\"PercentageDiff\":\"-0.10\",\"FiftyTwoWeekHigh\":\"183.50\",\"FiftyTwoWeekLow\":\"45.60\",\"LastTradedTime\":\"01 Sep,11:50:04\",\"ChangePercent\":\"-0.10\",\"Change\":\"-0.15\",\"MarketCap\":\"26,017.80\",\"High\":\"145.05\",\"Low\":\"142.70\",\"PrevClose\":\"143.05\"}]";
final Matcher m = Pattern.compile("\"([^\"]+)\":\"([^\"]+)\"").matcher(str);
while (m.find())
System.out.println(m.group(1) + "=" + m.group(2));
}
Similar Messages
-
Converting from spreadshet string to array and then back to spreadsheet string
My questions is; why is the Spreadsheet string to array function creating more data than the original string had when you change the array back into a spreadsheet string. Im trying to analyze a comma delimited file using array functions since my column and row size is constant, but my data varies. Thus my reason for not using string parsing functions which would get more involved and difficult. So, however, after i convert to a 2D array of data from the comma delimited file I read from, and then I convert back to string using the Array to Spreadsheet String, I get added columns to the file, which prevents another program from receiving these files. Also, the data which I am reading is not all contiguous, it has gaps in some places for empty data. Looking at the file compared to the original after it has gone from string to array and then back to string again, looks almost identical except for the file size which got larger by 400 bytes and where the original file has empty spaces, the new file has a lot of commas added. Any idea?
CharlesThe result you get is normal when the spreadsheet string contains rows of uneven length. Since the array rows have the same number of elements, nil values are added during the coonversion. And of course, the back to string conversion keep those added values in the string, with the associated commas.
example : 3 x 3 array
1,2,3
4
5,6,7
is converted into
1 2 3
4 0 0
5 6 7
then back to
1,2,3
4,0,0
5,6,7
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left... -
Unexpected behavior of spreadsheet string to array function
Hello,
I found some weirdness in LabVIEW 2011 that I do not understand. In the attached vi, I provide a one-dimensional spreadsheet string separated by spaces. I use the spreadsheet string to array function to convert this spreadsheet string into an array of strings.
I ran into problems when I wanted to specify a space character as the delimiter.
The conversion works as intended, if I do not specify a delimiter (i.e., the default tab delimiter is used). But if I specify the delimiter, only the first element of the spreadsheet string is converted. I do not understand this behavior.
Thanks for your help.
Peter
Solved!
Go to Solution.
Attachments:
Test spreadsheet string to array.vi 9 KBYou don't have spaces in your string. You have tabs and of course the default delimiter works. Right click and select '\' Codes Display and see the \t.
-
While developing and profiling a batch data-analysis program, I found that the "Read From Spreadsheet File.vi" function was where the majority ofthe execution time was spent. Digging further, I found the time was spent in the "Spreadsheet String To Array" function. Obviously I cannot look inside this function, but I wondered if I can somehow speed it up. Attached is a Vi that illustrates what I came up with as an alternative.
Basically using "Spreadsheet String To Array" only to split it up to a 2D String Array, and then "Fract/Exp String to Number" to convert the strings to numbers.
It consistently runs in just over 60% of the time of using Spreadsheet String To Array on it's own to do the conversion.
I am curious as to why using the two functions is quicker than just the one on it's own? Perhaps NI can improve the internals a bit? Or perhaps it is not a fair comparison?
Labview 8.6f1 Win XP SP2
Message Edited by pauldavey on 03-25-2009 02:55 PM
Attachments:
Speed Test Spreadsheet String to Array.vi 26 KBAdding a couple of other conversions to test against i noticed that:
1. Scan from string through a double loop was the slowest
2. Scan Value was slightly faster
3. Direct conversion through Spreadsheet to array as in OP
4. 2-step convert through Fract/Exp.
Could it be that Spreadsheet to array uses Scan Value internally?
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
Req help in conversion of string to array of args
Hi,
i need help in converting a string into array of args just like command line args
i have a string s1 = 12 13 56 etc
now i want to copy that into an array a[]
a[0] = 12
a[1] = 13 etc
Thanks for helpU can use String tokenizer.Why prefer that over split?Yah Bobby u can use split too..
J2SE 1.4 added the split() method to simplify the task of breaking a string into substrings, or tokens.
Thanks BigDaddy.. I realized after you told.
try this too..
String str = "Your string";
String[] arr = str.split (" ");
for (int i=0; i < arr.length; i++)
System.out.println (arr); -
How to search for particular string in array?
I am struggling to figure out how to search array contents for a string and then delete the entry from the array if it is found.
The code for a program that allows the user to enter up to 20 inventory items (tools) is posted below; I apologize in advance for it as I am also not having much success grasping the concept of OOP and I am certain it is does not conform although it all compiles.
Anyway, if you can provide some assistance as to how to go about searching the array I would be most grateful. Many thanks in advance..
// ==========================================================
// Tool class
// Reads user input from keyboard and writes to text file a list of entered
// inventory items (tools)
// ==========================================================
import java.io.*;
import java.text.DecimalFormat;
public class Tool
private String name;
private double totalCost;
int units;
// int record;
double price;
// Constructor for Tool
public Tool(String toolName, int unitQty, double costPrice)
name = toolName;
units = unitQty;
price = costPrice;
public static void main( String args[] ) throws Exception
String file = "test.txt";
String input;
String item;
String addItem;
int choice = 0;
int recordNum = 1;
int qty;
double price;
boolean valid;
String toolName = "";
String itemQty = "";
String itemCost = "";
DecimalFormat fmt = new DecimalFormat("##0.00");
// Display menu options
System.out.println();
System.out.println(" 1. ENTER item(s) into inventory");
System.out.println(" 2. DELETE item(s) from inventory");
System.out.println(" 3. DISPLAY item(s) in inventory");
System.out.println();
System.out.println(" 9. QUIT program");
System.out.println();
System.out.println("==================================================");
System.out.println();
// Declare and initialize keyboard input stream
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
do
valid = false;
try
System.out.print(" Enter an option > ");
input = stdin.readLine();
choice = Integer.parseInt(input);
System.out.println();
valid = true;
catch(NumberFormatException exception)
System.out.println();
System.out.println(" Only numbers accepted. Try again.");
while (!valid);
while (choice != 1 && choice != 2 && choice != 9)
System.out.println(" Not a valid option. Try again.");
System.out.print(" Enter an option > ");
input = stdin.readLine();
choice = Integer.parseInt(input);
System.out.println();
if (choice == 1)
// Declare and initialize input file
FileWriter fileName = new FileWriter(file);
BufferedWriter bufferedWriter = new BufferedWriter(fileName);
PrintWriter dataFile = new PrintWriter(bufferedWriter);
do
addItem="Y";
System.out.print(" Enter item #" + recordNum + " name > ");
toolName = stdin.readLine();
if (toolName.length() > 15)
toolName = toolName.substring(0,15); // Convert to uppercase
toolName = toolName.toUpperCase();
dataFile.print (toolName + "\t");
do
valid = false;
try
// Prompt for item quantity
System.out.print(" Enter item #" + recordNum + " quantity > ");
itemQty = stdin.readLine();
// Parse integer as string
qty = Integer.parseInt (itemQty);
// Write item quantity to data file
dataFile.print(itemQty + "\t");
valid=true;
catch(NumberFormatException exception)
// Throw error for all non-integer input
System.out.println();
System.out.println(" Only whole numbers please. Try again.");
while (!valid);
do
valid = false;
try
// Prompt for item cost
System.out.print(" Enter item #" + recordNum + " cost (A$) > ");
itemCost = stdin.readLine();
// Parse float as string
price = Double.parseDouble(itemCost);
// Write item cost to data file
dataFile.println(fmt.format(price));
valid = true;
catch(NumberFormatException exception)
// Throw error for all non-number input (integers
// allowed)
System.out.println();
System.out.println(" Only numbers please. Try again.");
while (!valid);
// Prompt to add another item
System.out.println();
System.out.print(" Add another item? Y/N > ");
addItem = stdin.readLine();
while ((!addItem.equalsIgnoreCase("Y")) && (!addItem.equalsIgnoreCase("N")))
// Prompt for valid input if not Y or N
System.out.println();
System.out.println(" Not a valid option. Try again.");
System.out.print(" Add another item? Y/N > ");
addItem = stdin.readLine();
System.out.println();
// Increment record number by 1
recordNum++;
if (addItem.equalsIgnoreCase("N"))
System.out.println();
System.out.println(" The output file \"" + file + "\" has been saved.");
System.out.println();
System.out.println(" Quitting program.");
while (addItem.equalsIgnoreCase("Y"));
// Close input file
dataFile.close();
if (choice == 2)
try {
Read user input (array search string)
Search array
If match found, remove entry from array
Confirm "deletion" and display new array contents
catch block {
} // class
// ==========================================================
// ListToolDetails class
// Reads a text file into an array and displays contents as an inventory list
// ==========================================================
import java.io.*;
import java.util.StringTokenizer;
import java.text.DecimalFormat;
public class ListToolDetails {
// Declare variable
private Tool[] toolArray; // Reference to an array of objects of type Tool
private int toolCount;
public static void main(String args[]) throws Exception {
String line, name, file = "test.txt";
int units, count = 0, record = 1;
double price, total = 0;
DecimalFormat fmt = new DecimalFormat("##0.00");
final int MAX = 20;
Tool[] items = new Tool[MAX];
System.out.println("Inventory List");
System.out.println();
System.out.println("REC.#" + "\t" + "ITEM" + "\t" + "QTY" + "\t"
+ "PRICE" + "\t" + "TOTAL");
System.out.println("\t" + "\t" + "\t" + "\t" + "PRICE");
System.out.println();
try {
// Read a tab-delimited text file of inventory items
FileReader fr = new FileReader(file);
BufferedReader inFile = new BufferedReader(fr);
StringTokenizer tokenizer;
while ((line = inFile.readLine()) != null) {
tokenizer = new StringTokenizer(line, "\t");
name = tokenizer.nextToken();
try {
units = Integer.parseInt(tokenizer.nextToken());
price = Double.parseDouble(tokenizer.nextToken());
items[count++] = new Tool(name, units, price);
total = units * price;
} catch (NumberFormatException exception) {
System.out.println("Error in input. Line ignored:");
System.out.println(line);
System.out.print(" " + count + "\t");
System.out.print(line + "\t");
System.out.print(fmt.format(total));
System.out.println();
inFile.close();
} catch (FileNotFoundException exception) {
System.out.println("The file " + file + " was not found.");
} catch (IOException exception) {
System.out.println(exception);
System.out.println();
// Unfinished functionality for displaying "error" message if user tries to
// add more than 20 tools to inventory
public void addTool(Tool maxtools) {
if (toolCount < toolArray.length) {
toolArray[toolCount] = maxtools;
toolCount += 1;
} else {
System.out.print("Inventory is full. Cannot add new tools.");
// This should search inventory by string and remove/overwrite matching
// entry with null
public Tool getTool(int index) {
if (index < toolCount) {
return toolArray[index];
} else {
System.out
.println("That tool does not exist at this index location.");
return null;
} // classData file contents:
TOOL 1 1 1.21
TOOL 2 8 3.85
TOOL 3 35 6.92Ok, so you have an array of Strings. And if the string you are searching for is in the array, you need to remove it from the array.
Is that right?
Can you use an ArrayList<String> instead of a String[ ]?
To find it, you would just do:
for (String item : myArray){
if (item.equals(searchString){
// remove the element. Not trivial for arrays, very easy for ArrayList
}Heck, with an arraylist you might be able to do the following:
arrayList.remove(arrayList.indexOf(searchString));[edit]
the above assumes you are using 1.5
uses generics and for each loop
[edit2]
and kinda won't work it you have to use an array since you will need the array index to be able to remove it. See the previous post for that, then set the value in that array index to null.
Message was edited by:
BaltimoreJohn -
Apparent inconsistency of "spreadsheet string to array"
System: LabView6.1, XPpro, 512MB, 2.4GHz
I have a sub-vi which I call to read a single column of data from a large CSV file. Files can be >500000 rows with 4-8 cols (ie. 15-30MB). The sub-vi uses "Read File", with byte stream type unwired, to return a string. This string is then passed to "spreadsheet string to array" (SStA), to obtain a 2D array. "Index Array" is then used to obtain the required data column.
If I wire the format string of SStA with %f, and the array type with a 2D double, the sub-VI takes about 8 seconds every time I call it.
If I wire format string with %s, and array type with 2D string (and convert to a double later, after index array), the sub-VI takes over 50s the first time it is c
alled, but only about 1s on each subsequent call.
The bottle neck is ONLY at SStA. I am not explicitly preallocating any arrays.
Can anyone explain what LabView is doing internally with respects to memory allocation? Why is the second routine slow on the first call only, and subsequently considerably faster than the first routine? Is there any alternative way of "priming" the second sub-vi so it is not slow on the first call? I guess reading only subsets of data at a time might help, but I'd still like to understand what is going on with the current approach.Roo Payne wrote:
> Can anyone explain what LabView is doing internally with respects to
> memory allocation? Why is the second routine slow on the first call
> only, and subsequently considerably faster than the first routine? Is
> there any alternative way of "priming" the second sub-vi so it is not
> slow on the first call? I guess reading only subsets of data at a time
> might help, but I'd still like to understand what is going on with the
> current approach.
Basically NI seems to have added some performance optimization with
internal caching to the Spreadsheet String to Array function in the case
of String outputs. Without it it would always take 50 seconds. If the
input string does change significantly it probably won't be such a huge
speed up anymore.
For numeric type outputs no caching has been added and wouldn't help
that much in comparison.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Issues with spreadsheet string to array
Hi, I have a spreadsheet string (tab delimited) and I am trying to convert it into an array of double with 6 digits of precision after the decimal point. However, as shown in the attached example, the function "spreadsheet to array" is not giving me the desired digit of precision (only 2 after decimal point). I have tried almost everything and I am frustrated with this function. CAN SOMEONE PLZ HELP ME ??
Attachments:
Block diagram.png 13 KB
String to array double.vi 10 KB
Panel.png 28 KBI have no LV 8.x installed, so I can't check your Code. But it might be your settings for the indicator. In LV 7.1 it defaults to 6 significant digits, that means the reading is 12345,6789 but (only) your indicator displays 12345,6.
Right click on your indicator (Front Panel) and go to formatting.
Felix
www.aescusoft.de
My latest community nugget on producer/consumer design
My current blog: A journey through uml -
Optimize function to correct a string to be converted to number
Hi,
I have imported almost 6.5 milion rows into a table (using sql loader) from a flat file (which contains the NUL caracter (ASCII 0) - not space, not NULL). To make the load easier I set the datatype as VARCHAR2 for all columns. For columns with string data I used a TRIM(REPLACE(field,' ','')) to get rid of the NUL and it works.
But for the column that must be converted to numeric I am trying to use to_number () function and it fails because the numeric data is mixed with other characters.
To solve this problem I created this function :
CREATE OR REPLACE
FUNCTION string_to_number
(p_string_source IN VARCHAR2 ) RETURN VARCHAR2 IS v_output_string varchar2(150);
-- This function takes a string as parameter and has 2 outputs:
-- 1. If the source string cannot be converted to number throw 'Error' as the output message to identify the line with the issue
-- 2. A string that can be converted successfully as Number;
-- The necessity of this function came up after an import from a flat file where the resulted string contained strange characters shown as spaces
--check if '-' is exists and is on the first position or if in the source string exists more than one '.'
-- ASCII codes accepted in the string :
-- 45 '-' ; 46 '.' ; from 48 (0) to 57 (9)
BEGIN
DECLARE v_minus VARCHAR2(1);
v_dot INTEGER;
BEGIN
SELECT substr(p_string_source,1,1) INTO v_minus FROM dual;
SELECT instr(p_string_source,'.',1,2) INTO v_dot FROM dual;
--check if '-' is exists and is on the first position or if in the source string exists more than one '.'
-- ASCII codes accepted in the string :
-- 45 '-' ; 46 '.' ; from 48 (0) to 57 (9)
IF v_minus NOT IN ('-','.','0','1','2','3','4','5','6','7','8','9')
-- or there are two dots '.' in the string
OR v_dot <> 0
THEN v_output_string := 'Error';
ELSE
BEGIN
-- for every character of the string we'll check if it's a number to add it to the outcome string;
-- if it's not an accepted character it will be ignored
DECLARE v_length_source int := length(p_string_source);
v_counter int :=1;
v_add_in_number VARCHAR2(1);
BEGIN
FOR v_counter IN 1..v_length_source LOOP
BEGIN
SELECT SUBSTR(p_string_source,v_counter,1) into v_add_in_number from dual;
IF v_add_in_number IN ('-','.','0','1','2','3','4','5','6','7','8','9')
THEN v_output_string := v_output_string ||v_add_in_number;
END IF;
END;
END LOOP;
END;
-- in case the string is in format '.00034' we'll add a 0 in front of the string to be accepted as argument by TO_NUMBER function
IF v_minus = '.'
THEN v_output_string := '0'||v_output_string;
ELSE
BEGIN
v_output_string := v_output_string;
END;
END IF;
END;
END IF;
END;
RETURN v_output_string;
END;
The main idea is to check every string (the parameter will be the value from the Amount column) for permitted characters that compose a numeric value:
1. To begins with numeric, '-' or '.'
2. To have only one '.' (as a decimal separator);
3. To compare every character of the string with the permitted ones - the non-compliant will be rejected
This way the resulting string (v_output_string) will be successfully converted to number
I admit that I don't have much experience using PL/SQL that is why I am asking your help to optimize this function to improve its performance. Could you help me on this, please ?
TIA,
JohnP
Edited by: petresion on 04-Oct-2012 01:33Perform a function here on all 6.5 million of rows will never be efficient.
I would modify Peter's approach a little bit,
1. Load directly into staging t1 without any checking (or create an external table)
2. Transfer from t1 to a list partitioned t2 with list values in ('yes', 'no','null','other')
--simple check using translate()
3. Apply your special function only on rows in the 'other' partition (hopefully much fewer rows left)
--other checks -
Cp-1251 utf-8 converting: problems with russian letters
Hello every one!
I have faced a major problem in cp-1251 to utf8 string convertion (in Windows):
String result2 = new String(result.getBytes("utf8"), Charset.forName("cp-1251"));Everything works fine, but there is a problem with russian letter И (10th letter in the alphabeth).
cp-1251 byte code of И is 200
The right byte code for И in utf-8 is : 208 152, but I recieve the byte code 208 63 for И. So there must be some mistake.
So, when i try to read this string, i face a problem with wrong utf-8 charset...
I tried this code on Debian, everything works fine.
I will be glad if you are capable of helping me.
Thank you.
Edited by: smikler on Sep 27, 2009 10:25 AM
Edited by: smikler on Sep 27, 2009 10:27 AMYour code makes no sense.
You're taking a String and asking for it to be turned into a stream of bytes according to the UTF-8 character encoding. And then you're giving these bytes back and asking to have them interpreted back into characters using the CP-1251 character encoding. This is bound to fail, because the bytes aren't in CP-1251 - they're in UTF-8 as you requested.
The very concept of changing the character encoding of a String is meaningless. Strings in Java are represented in Unicode. It's only when you convert to and from bytes (using the two methods you've used) that you worry about encoding/decoding.
So, why not describe what you're actually trying to achieve? -
String to Byte convertion related question. SMS related
Hi all
I need to ask more indepth question regarding string to bytes convertion. I need to have a constructed message format with a length of 161 bytes. Here's are the details:-
String message - 160 bytes allocation.
Message length - 1 byte allocation.
For converting the message string into byte I can use
byte b1[] = message.getBytes();
And i know to get the length of the message I can just use
message.length();
So my questions are :-
1) I need some help on how i'm supposed to convert the length message values and assign it into the message length variables which have 1 byte allocation.
2) Besides text, the message string can also be a hex value data. Hence it it possible that I can convert the hex data into byte and still maintain within the 160 bytes allocation ? Coz most of the times the hex data length will be > 160 but < 255 characters length. example :-
06050415810000024a3a7d35bd35bdb995e535bd41c9bd89b194040082986417614819817624e3105d85206605e09390391394417817817819817824e40e44e5104a04a04a05205105d85206605d8938c417614819817824e40e44e5105e05e05e06605e093903913944128128128148146800
Anyone can help ?
Thank You in AdvancedFirst of all. One character in a string can occupie
more than one byte in the destination array, so
String.length can be != bytes.length.
A byte in java is always signed, so the value will be
in the range -128 to +127.
KajHi Kaj,
Since you put it in that way, is there any tips u can give me on how I'm supposed to calculate the length of the string and set the value in byte ?
Or do I need to convert the string into bytes array first and then get the length ?
Thanks -
Parse string into array for comparison
Hi All,
I am trying to parse a string message into an array of numbers so I can check if my event was successful.
\FF\FE\01\FD\02\00\00\00
I know I just need to read through and discard the \, but I don't know how to do that in Labview. I just need to check if the 6th byte = 00 or not.
Thanks! I mostly need help with parsing in labview.Assuming this is a plain ASCII string containing the letters 0..F and "\" as delimiter, you can simply used "Spreadsheet string to array" with the following settings:
Type= 1D U8 array
format= %x
delimiter= "\"
One problem is the extra delimiter at the beginning, so use array subset to skip the first element.
(EDIT: Ahh, Darin beat me with a similar solution. Mine's a little easier ).
Message Edited by altenbach on 08-06-2009 04:30 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
StringToArray.png 13 KB -
Spreadshee​t string to array slow?
We have an apllication here where we would like to save all our data 120
files with 4M each and then read it back.
I ve changed now to zipped files, but reading from the disk seems not to
be the problem. I used 'profile' to analyze the time consumption. I
think it might be the 'spreadsheet string to array VI' which makes it so
slow, 1 second is a lot to sort 450k numbers. (BTW its a win2000 PC of
this year)
Any hints how to improve it?
Best Regards
Urs Böglihi,
I do this small program. Program generate, write and read array with double precision. I generated array with 1.000.000 rows and 10 columns. Read is fast in this program, because file is 'cached' in Windows Virtual Memory.
When you close LabVIEW and try read file with second VI on my PC I need 3 second for this array [on the disk have file 80MB].
It is programs in LabVIEW 7.0
Attachments:
readArrayFile.zip 186 KB -
Spreadshee​t string to array notation
Hi all,
I am using the spreadsheet string to array function and basically my problem is as follows:
My inputs are in scientific notation so I use this in string format. The data is separated with a ",". What I get is just the argument rounded.
As I just realized I didn´t make myself clear I´ve attached a photo of the problem. Notice that probe 4 is the input from which I want to build the array, and probe 5 is the output. I just have the 9 but what happens with the rest of the number?
PD: I´ve tried many formats but none of them seems to work.
Thank for your help
Solved!
Go to Solution.
Attachments:
notation.png 145 KBYour system is set up to use a comma (,) as the decimal point? Try using "%.;%^.3e" for your format. The "%.;" tells the scan to use the period as the decimal point.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Fast spreadsheet string to array
Is there any faster (more effiecient) method of converting a spreadsheet string (simple tabbed single precision floating points) to an array than using "Spreadsheet String to Array"? This seems to be the bottleneck in a program I'm working on. Thanks!
2006 Ultimate LabVIEW G-eek.Not really, how large is the string you are trying to convert? The only real alternative is to convert the string in smaller bits, or perhaps collect the data in an array in the first place.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
Maybe you are looking for
-
Safari won't open from new hard drive
i installed a new ssd drive and loaded the backup of my old drive from time machine onto it. everything seemed okay until i tried to open safari and nothing happens! anyone have any idea why this would happen before i try starting over? do you thi
-
Opening an .rar file and converting flac files
I am not sure this belongs in this topic area but since iTunes is the ultimate destination of this file I posted here. I have a .rar file. It is a compressed file when unzipped will have FLAC audio files in the folder. I need to know how I unzip the
-
HELP! Games quit with memory writing errors
Hello I have Barton 2500+ Unlocked; I run it on 11x200, the system run stable on general But when I play games, the games quit with memory writing errors, I have good Kingston RAM, and it should run on 200 FSB without any problem, I saw many people r
-
Updated ThinkVantage - now doesn't work
I have a new (3 days old) T410s. I opened the Lenovo ThinkVantage Toolbox, and noticed there was an update, so I updated it. Now, when I try to run the Toolbox, I get the following message: 'This version of Lenovo ThinkVantage Toolbox is not licens
-
It seems like the snap to beats functionality has disappeared so how do you sync songs to your photos/videos in a fairly quick manner ?