Conversion​: engineerin​g string to fractional string
Hello everyone
I am loading a text file with several columns that has text (informations about the file and column titles) and values in engineering format. After I load this file I use "spreadsheet string to array" to convert it to 2D array of strings.
I would like to leave all the "text" (informations about the file and column titles) unchanged, but I want all the "engineering values" to be converted to "fractional values". How do I convert an engineering string to a fractional string?
I will have to convert the whole file at once because different files have different positions for text and engineering values and because of that would be impossible to know the index of values and convert just them.
Thanks.
Dan07
Solved!
Go to Solution.
Hi Dan,
conversion is done like that:
But you have to select, what is text and what is number, on your own. How should LabVIEW know about your file format?
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Similar Messages
-
Number to fractional string not working correctly
I am measuring some parameters from oscillsocpe. i need to write these values to text file for which i am using write to spreadsheet, but what is happening is it is always writing zero value to file, on debugging i found that while converting from number to string it is always writng zero to string indicator, then separately i used that number to fractional string indicator and it is always showing zero in string output , i dont why it is happening.
Attached below is the code.
Solved!
Go to Solution.
Attachments:
Time meas sub.vi 31 KBRanjeet Singh and Norbert_B
Thanks for ther reply
Ranjeet singh,
number to fractional string is working correctly, there is some other problem, because inly when i am executing this code converting this rise time value to string then only it is showing zero, otherwise for any random number if i am checking this number to fractional string is working correctly.
Norbert_B
i dont need to convert it back to string that i am doing only to check why it is showing zero value on converting number to string , because when i was writing to spreadsheet file it was always writing zero value, so when checked that code it was observed that while converting from array of numbers to spreadsheet string it is always writing zero value that's why i am doing it here just to check why it is not converting to string, but your suggestion helped in focussing the string that i am gettong from VISA read, i can use that in last case if i wont be able to find the solution but main problem is that why i am not able to convert it back to string, why it is showing zero because it is because of this only write to spreadsheet is always showing zero value . -
hi ....
i am very new to the NI Labview, anybody help me to explain the number to fractional string, which are used in following block diagram.
what is the motto behind using the number to fractional sting and please do not suggest me to read context help on this topic.
Attachments:
tab-grap1407.vi 152 KB23235573 wrote:
hi ....
... please do not suggest me to read context help on this topic.
Hi 23235573,
why not? The context help describes what this function do. You can convert a number to a fractional string.
Mike -
String to 2D string array conversion
Hi,
I have a string like this below. I would like to extract all the texts within the quotes " ". How to do that?.
05-Mar.20:52 skalyana label type "BASELINE_1.2" (locked)
28-Apr.19:19 skalyana label type "BASELINE_1.8"
i have tried using Match regular expression. I am able to extract one text within " ".
I would like to know how to extract all the text within " "
I have attached the vi for your reference
Thanks
Kalyan
Attachments:
string to 2D string array conversion.vi 19 KBHi Jim,
its simply superb...
how to get more info on these 'Regular Expressions', is there any KB (knowledge base) or tutorial available for the same.
I am not allergic to Kudos, in fact I love Kudos.
Make your LabVIEW experience more CONVENIENT. -
Number to fraction string +format value
Hi there,
I just met a stupid question which made me crazy, please help.
The question is simple:
Target: Numeric floating control-> number to fraction string -> format value -> desirable string format
For example: 20.00 -> 20.00000 (Q1: why extra 0s?)-> "20.00"
I use the following program:
why doesn't it work, please?
Thanks!Hi TriStones,
"Why it doesn't work?"
Because you haven't read the context help for "Number to fractional string"! Especially the sentences on those two additional inputs of that function (Q1)...
I would suggest using FormatIntoString like that:
(I tried to replicate your example, but your wiring is very bad: it's not clear which wire is connected to which input...)
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
JSP String != JavaScript String
I've run across a problem that has intrigued me. Consider the following:
<% String test = new String();
test = "Hello Mr. Anderson...";
%>
<script language="javascript">
function doThis() {
alert("TEST: " + "<%=test%>");
</script>
// No problem, will work just fine. Now add an escape sequence (\n)
// to the test string
<% String test = new String();
test = "Hello Mr. Anderson...\n";
%>
<script language="javascript">
function doThis() {
alert("TEST: " + "<%=test%>");
</script>
Now we get
error: Unterminated string constant
on any call to doThis(). Why????? Javascript has wrappers around it's primitive data types as well, so I was thinking the conversion should be smooth here. Any experts out there know what's happening here?
Thanks,
ChrisThe reason is you are printing out what's in the Java string to the browser, and that results in this:
"Hello Mr. Anderson...
So, as the first responder said, you need to escape the \n with \\n, which will write:
"Hello Mr. Anderson...\n"
in the browser, which will get translated in the Javascript parser as a new line. -
Null String and Empty String problem
Hello everyone,
since i am totally new in JSP, i am getting problem in handling strings.
Suppose i have a variable users = ""; then
I want to ask when to use:
if (users.equals(""))
and
if(users == "")
in my code, variable users has value "regional" for regional users.
and i am checking this code as:
if (users.equals{"regional")) {
out.print ("I am inside code");
at that time, the code is throwing error (run time error)
and when i changed the code as:
if (users == "regional") {
out.print ("I am inside code");
this time, the code is not generating error but the part message "I am inside code " is not displaying. The code do not inserts inside the if condition
I hope u understand my problem. Can anybody help me out with this.This has basically nothing to do with JSP, but with basic Java knowledge.
When using the '==' operator to compare Objects (yes, String is actually a subclass of Object), then it will look if they are of the same reference. Using the '==' operator to compare primitive datatypes (int, boolean, char, etc) will look if they have the same value.
That is why the Object class has the equals() method to give the ability compare with another objects. And you can only invoke it when the Object is actually instantiated. So if it is not null.
if (string != null && string.equals("somevalue")) {
// or
if ("somevalue".equals(string)) {
}should work.
Edit rym82: this will not throw a NPE, but an ordinary compilation error ;)
Message was edited by:
BalusC -
What is difference between Null String and Empty String ?
Hi
Just i have little confusion that the difference bet'n NULL String and Empty String ..
Please clear my doubte.
ThankxFor the same reason I think it's okay to say "null
String" and "empty String "as long as you know they
really mean "null String reference" and "empty String
object" respectively. Crap. It's only okay to say that as long as *the one you're talking to" knows what it really means. Whether you know it or not is absolutely irrelevant. And there is hardly any ambiguity about the effects that a statement like "assign an object to a reference" brings. "Null String" differs in that way. -
Difference between String and final String
Hi friends,
This is Ramana. Can u suggest me in this Question
What is the difference between String and final String? Means
String str="hai";
final String str="hai";
Regards,
Ramana.*******REPEAT POST***********
We already answered your question why post in a different section?
http://forum.java.sun.com/thread.jspa?threadID=5201549 -
How can I replace a String in a String ,for example :
in the String "Hello World" replace Hello with Bye" ?
Is there a class or code I can find for that purpose?use an utility method like this :
I did not found an existing method doing this in java.lang.String or StringBufer
public static String replaceFirstSubstring(
String stringToSubstitute, String searchString, String replaceString) {
if (stringToSubstitute == null) {
return null;
int prefixEndIndex = stringToSubstitute.indexOf(searchString);
if (prefixEndIndex == -1) {
return stringToSubstitute;
int suffixStartIndex = prefixEndIndex + searchString.length();
StringBuffer newString = new StringBuffer(stringToSubstitute.substring(0, prefixEndIndex));
newString.append(replaceString).append(stringToSubstitute.substring(suffixStartIndex));
return newString.toString();
put it in a while if you need to replace more than 1 time -
Whats the difference in creating String from CharBuffer by using array and by using toString() ?
When ever i have some UTF-8 chars in my file (""someFile"), String created from new String( charBuffer.array()) appends some extra null/junk charaters at the very end of the file.
How ever when i try charBuffer.toString() its working fine.
For simple ASCII i.e ISO-*** charset both methods are working fine.
Please see below code for reproducing. Here "someFile" is any text file with some UTF-8 characters.
public char[] getCharArray()
throws IOException
Charset charset = Charset.forName("UTF-8");
CharsetDecoder decoder = charset.newDecoder();
FileInputStream fis = new FileInputStream("someFile");
FileChannel channel = fis.getChannel();
int size = (int) channel.size();
MappedByteBuffer mbb = channel.map(FileChannel.MapMode.READ_ONLY, 0 , size);
CharBuffer cb = decoder.decode(mbb);
channel.close();
fis.close();
return cb.array();
public String getAsString()
throws IOException
Charset charset = Charset.forName("UTF-8");
CharsetDecoder decoder = charset.newDecoder();
FileInputStream fis = new FileInputStream("someFile");
FileChannel channel = fis.getChannel();
int size = (int) channel.size();
MappedByteBuffer mbb = channel.map(FileChannel.MapMode.READ_ONLY, 0 , size);
CharBuffer cb = decoder.decode(mbb);
channel.close();
fis.close();
return cb.toString();
String fromToString = getAsString();
String fromCharArray = new String(getCharArray());Whats the difference in creating String from CharBuffer by using array and by using toString() ?array() returns the entire backing array regardless of offset and position. toString() takes those into account.
When ever i have some UTF-8 chars in my file (""someFile"), String created from new String( charBuffer.array()) appends some extra null/junk charaters at the very end of the file.More probably you haven't filled the array.
How ever when i try charBuffer.toString() its working fine.So there you go. -
Replacing a special character in a string with another string
Hi
I need to replace a special character in a string with another string.
Say there is a string - "abc's def's are alphabets"
and i need to replace all the ' (apostrophe) with &apos& ..which should look like as below
"abc&apos&s def&apos&s are alphabets" .
Kindly let me know how this requirement can be met.
Regards
SukumariREPLACE
Syntax Forms
Pattern-based replacement
1. REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF]
pattern
IN [section_of] dobj WITH new
[IN {BYTE|CHARACTER} MODE]
[{RESPECTING|IGNORING} CASE]
[REPLACEMENT COUNT rcnt]
{ {[REPLACEMENT OFFSET roff]
[REPLACEMENT LENGTH rlen]}
| [RESULTS result_tab|result_wa] }.
Position-based replacement
2. REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
[IN {BYTE|CHARACTER} MODE].
Effect
This statement replaces characters or bytes of the variable dobj by characters or bytes of the data object new. Here, position-based and pattern-based replacement are possible.
When the replacement is executed, an interim result without a length limit is implicitly generated and the interim result is transferred to the data object dobj. If the length of the interim result is longer than the length of dobj, the data is cut off on the right in the case of data objects of fixed length. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or hexadecimal zeroes. Data objects of variable length are adjusted. If data is cut off to the right when the interim result is assigned, sy-subrc is set to 2.
In the case of character string processing, the closing spaces are taken into account for data objects dobj of fixed length; they are not taken into account in the case of new.
System fields
sy-subrc Meaning
0 The specified section or subsequence was replaced by the content of new and the result is available in full in dobj.
2 The specified section or subsequence was replaced in dobj by the contents of new and the result of the replacement was cut off to the right.
4 The subsequence in sub_string was not found in dobj in the pattern-based search.
8 The data objects sub_string and new contain double-byte characters that cannot be interpreted.
Note
These forms of the statement REPLACE replace the following obsolete form:
REPLACE sub_string WITH
Syntax
REPLACE sub_string WITH new INTO dobj
[IN {BYTE|CHARACTER} MODE]
[LENGTH len].
Extras:
1. ... IN {BYTE|CHARACTER} MODE
2. ... LENGTH len
Effect
This statement searches through a byte string or character string dobj for the subsequence specified in sub_string and replaces the first byte or character string in dobj that matches sub_string with the contents of the data object new.
The memory areas of sub_string and new must not overlap, otherwise the result is undefined. If sub_string is an empty string, the point before the first character or byte of the search area is found and the content of new is inserted before the first character.
During character string processing, the closing blank is considered for data objects dobj, sub_string and new of type c, d, n or t.
System Fields
sy-subrc Meaning
0 The subsequence in sub_string was replaced in the target field dobj with the content of new.
4 The subsequence in sub_string could not be replaced in the target field dobj with the contents of new.
Note
This variant of the statement REPLACE will be replaced, beginning with Release 6.10, with a new variant.
Addition 1
... IN {BYTE|CHARACTER} MODE
Effect
The optional addition IN {BYTE|CHARACTER} MODE determines whether byte or character string processing will be executed. If the addition is not specified, character string processing is executed. Depending on the processing type, the data objects sub_string, new, and dobj must be byte or character type.
Addition 2
... LENGTH len
Effect
If the addition LENGTH is not specified, all the data objects involved are evaluated in their entire length. If the addition LENGTH is specified, only the first len bytes or characters of sub_string are used for the search. For len, a data object of the type i is expected.
If the length of the interim result is longer than the length of dobj, data objects of fixed length will be cut off to the right. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or with hexadecimal 0. Data objects of variable length are adapted.
Example
After the replacements, text1 contains the complete content "I should know that you know", while text2 has the cut-off content "I should know that".
DATA: text1 TYPE string VALUE 'I know you know',
text2(18) TYPE c LENGTH 18 VALUE 'I know you know',
sub_string TYPE string VALUE 'know',
new TYPE string VALUE 'should know that'.
REPLACE sub_string WITH new INTO text1.
REPLACE sub_string WITH new INTO text2. -
I need to append a string to another string
I'm working with some inherited code, I'm a Colf Fusion
novice myself, and I'm trying to make this order form display the
correct data. The problem is a lot of data in the database is
missing. Description in the QStockDB query can contain a lot of
stuff. For our full color work the text "4/0", "4/BLACK", and "4/4"
are consistent so I'm changing the newitem (I know, not very
descriptive but it's not my code) to CMYK Printing.
<cfif #QStockDB.description# contains "4/0"><cfset
newitem = "CMYK Printing"></cfif>
<cfif #QStockDB.description# contains
"4/4/BLACK"><cfset newitem = "CMYK Printing"></cfif>
<cfif #QStockDB.description# contains "4/4"><cfset
newitem = "CMYK Printing"></cfif>
I want to then go back through description and compare it
more to add more description. For instance with this:
<cfif #QStockDB.description# contains "12 pt"><cfset
newitem = newitem + " - BC"></cfif>
I know that the job is a business card. So I want to append
the newitem variable with " - BC". Likewise:
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem + " - Catalog
Sheets"></cfif>
displays CMYK Printing - Catalog Sheets. Or, it should... or,
more precisely, I want it to. :)
How do I append a string to another string?+ is the addiion operator and works with numbers. Because
your string is a ...well, string... you need to use an ampersand.
Thus, instead of:
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem + " - Catalog
Sheets"></cfif>
Use...
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem & " - Catalog
Sheets"></cfif>
<cfoutput>#newitem#</cfoutput>
At least I think that will work - haven't tested it
though. -
Double.parseDouble(String) - problems when string is in scientific notation
Hello guys,
I'm doing some numerical calculations and I wonder whether it is possible for Double.parseDouble(String) to parse string in the scientific notation i.e. 1.0824234234E-10. Is it the notation itself causing the exception : NumberFormatException or the number is just too big/small and double can't hold it ?
If it's just the notation how can I fix it ?
Regardsi'm not quite sure whether double odoes not allow it.
perhaps consider the api Double.valueOf() and the testing code provided; reproduced below:To avoid calling this method on a invalid string and having a NumberFormatException be thrown, the regular expression below can be used to screen the input string:
final String Digits = "(\\p{Digit}+)";
final String HexDigits = "(\\p{XDigit}+)";
// an exponent is 'e' or 'E' followed by an optionally
// signed decimal integer.
final String Exp = "[eE][+-]?"+Digits;
final String fpRegex =
("[\\x00-\\x20]*"+ // Optional leading "whitespace"
"[+-]?(" + // Optional sign character
"NaN|" + // "NaN" string
"Infinity|" + // "Infinity" string
// A decimal floating-point string representing a finite positive
// number without a leading sign has at most five basic pieces:
// Digits . Digits ExponentPart FloatTypeSuffix
// Since this method allows integer-only strings as input
// in addition to strings of floating-point literals, the
// two sub-patterns below are simplifications of the grammar
// productions from the Java Language Specification, 2nd
// edition, section 3.10.2.
// Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
"((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
// . Digits ExponentPart_opt FloatTypeSuffix_opt
"(\\.("+Digits+")("+Exp+")?)|"+
// Hexadecimal strings
"((" +
// 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
"(0[xX]" + HexDigits + "(\\.)?)|" +
// 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
"(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
")[pP][+-]?" + Digits + "))" +
"[fFdD]?))" +
"[\\x00-\\x20]*");// Optional trailing "whitespace"
if (Pattern.matches(fpRegex, myString))
Double.valueOf(myString); // Will not throw NumberFormatException
else {
// Perform suitable alternative action
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html -
Converting from xsd:string into soapenc:string
Hi.
I was successfull in invoking an axis web service with complex type definitions.
However, when building and deploying the process flow, I get a warning message as follows:
" [bpelc] [Warning]: Trying to assign incompatible types
[bpelc] [Description]: in line 53 of "C:\eclipse\workspace\ComplexTypeWSFlow\TimeSheetProcess.bpel", <from> value type "{http://www.w3.org/2001/XMLSchema}string" is not compatible with <to> value type "{http://schemas.xmlsoap.org/soap/encoding/}string".
[bpelc] [Potential fix]: Please make sure that the return value of from-spec query is compatible with the to-spec query.
[bpelc]
[bpelc] [Warning]: Trying to assign incompatible types
[bpelc] [Description]: in line 58 of "C:\eclipse\workspace\ComplexTypeWSFlow\TimeSheetProcess.bpel", <from> value type "{http://www.w3.org/2001/XMLSchema}string" is not compatible with <to> value type "{http://schemas.xmlsoap.org/soap/encoding/}string".
[bpelc] [Potential fix]: Please make sure that the return value of from-spec query is compatible with the to-spec query."
My question is:
How can I convert between xsd:string and soapenc:string types when using the "assign" activity so I don't keep getting this warning message?
RegardsHi Paulo,
This warning has been fixed in recent builds. eventhough soapenc:string is different type, it extends xs:string and its simple content. the compiler shouldn't display warnings for this case.
Maybe you are looking for
-
Error with Provider Hosted App on Edit Form of a list item
We have an error on the Edit Form of one of our pages. We have developed a SharePoint Online Provider Hosted app which replaces the standard edit form of a list item and has some further events behind the save button. Since this is rather new territo
-
All sorts of problems transferring from one computer to another
This looked so easy on the Apple Website. I followed the instructions to the letter I am sure. Just bought a new computer using Vista. Wanted to transfer a 16gb library from the old computer to another. Used the iPod as the hard drive to do so. Manag
-
Original iPad mini had water damage, then sat around for 8 months.
I have an iPad mini with water damage that has been sitting around for 8 months. I woke up in the middle of the night and spilled water on it. It was plugged in and in an Otterbox. I unplugged it, took it out of the case, and dried it off. I then put
-
I'm getting ready (I hope) to upgrade my Garritan Personal Orchestra software to version 2.2.1. If there are any other GPO/Logic users reading this, and you have upgraded, have you noticed any performance glitches, plugin/sample loading errors (besid
-
Installing Solaris 8 in conjuction with win 98
Before I purchase Solaris 8, I would like to know how should I partition my drive; right now I have Win 98. I have partition magic, but it does not have a Unix format only a linux ext. Should I paratition my drive by leaving free space that is not fo