Search Results

Search found 19 results on 1 pages for 'delimeter'.

Page 1/1 | 1 

  • Problem while configuring the file Delimeter("\t") in app.config(C#3.0)

    - by Newbie
    In my app.config file I made the setting like the following <add key = "Delimeter" value ="\t"/> Now while accessing the above from the program by using the below code string delimeter = ConfigurationManager.AppSettings["FileDelimeter"].ToString(); StreamWriter streamWriter = null; streamWriter = new StreamWriter(fs); streamWriter.BaseStream.Seek(0, SeekOrigin.End); Enumerable .Range(0, outData.Length) .ToList().ForEach(i => streamWriter.Write(outData[i].ToString() + delimiter)); streamWriter.WriteLine(); streamWriter.Flush(); I am getting the output as 18804\t20100326\t5.59975381254617\t 18804\t20100326\t1.82599797249479\t But if I directly use "\t" in the delimeter variable I am getting the correct output 18804 20100326 5.59975381254617 18804 20100326 1.82599797249479 I found that while I am specifying the "\t" in the config file, and while reading it into the delimeter variable, it is becoming "\\t" which is the problem. I even tried with but with no luck. I am using C#3.0. Need help

    Read the article

  • which delimeter to use while spliting String

    - by London
    I need to split this line string in each line, I need to get the third word(film name) but as you see the delimeter is one big blank character in some cases its small like before the numbers at the end or its big as in front of numbers at front. I tried using string split with(" ") regex, and also \t but get the out of the bounds error. 400115305 Lionel_Atwill The_Song_of_Songs_(1933_film) 7587 400115309 Brian_Aherne A_Night_to_Remember_(1943_film) 7952 Did anyone have the same problem?

    Read the article

  • How to parse out html links from a huge string with html links and other text (Java).

    - by Robert
    Hello, my question is how would i be able to go through a string and take out only the links and erase all the rest? I thought about using some type of delemiter, but wouldnt know how to go about using it in java. an example of what i am trying to do: this is my String: String myString = "The file is http: // www. .com/hello.txt and the second file is " + "http: // www. .com/hello2.dat"; I would want the output to be: "http: // www. .com/hello.txt http: // www. .com/hello2.dat" or each could be added to an array, separately. I just want some ideas, id like to write the code myself but am having trouble on how to do it. Any help would be awesome.

    Read the article

  • Opengl problem with texture in model from obj

    - by subSeven
    Hello! I writing small program in OpenGL, and I have problem ( textures are skew, and I dont know why, this model work in another obj viewer) What I have: http://img696.imageshack.us/i/obrazo.png/ What I want http://img88.imageshack.us/i/obraz2d.jpg/ This code where I load texture: bool success; ILuint texId; GLuint image; ilGenImages(1, &texId); ilBindImage(texId); success = ilLoadImage((WCHAR*)fileName.c_str()); if(success) { success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); if(!success) { return false; } } else { return false; } glGenTextures(1, &image); glBindTexture(GL_TEXTURE_2D, image); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData()); ilDeleteImages(1, &texId); Code to load obj: triangles.clear(); std::ifstream in; std::string cmd; in.open (fileName.c_str()); if (in.is_open()) { while(!in.eof()) { in>>cmd; if(cmd=="v") { Vector3d vector; in>>vector.x; in>>vector.y; in>>vector.z; points.push_back(vector); } if(cmd=="vt") { Vector2d texcord; in>>texcord.x; in>>texcord.y; texcords.push_back(texcord); } if(cmd=="vn") { Vector3d normal; in>>normal.x; in>>normal.y; in>>normal.z; normals.push_back(normal); } if(cmd=="f") { Triangle triangle; std::string str; std::string str1,str2,str3; std::string delimeter("/"); int pos; int n; std::stringstream ss (std::stringstream::in | std::stringstream::out); in>>str; pos = str.find(delimeter); str1 = str.substr(0,pos); str2 = str.substr(pos+delimeter.length()); pos = str2.find(delimeter); str3 = str2.substr(pos+delimeter.length()); str2 = str2.substr(0,pos); ss<<str1; ss>>n; triangle.a= n-1; ss.clear(); ss<<str3; ss>>n; triangle.an =n-1; ss.clear(); ss<<str2; ss>>n; ss.clear(); triangle.atc = n-1; in>>str; pos = str.find(delimeter); str1 = str.substr(0,pos); str2 = str.substr(pos+delimeter.length()); pos = str2.find(delimeter); str3 = str2.substr(pos+delimeter.length()); str2 = str2.substr(0,pos); ss<<str1; ss>>n; triangle.b= n-1; ss.clear(); ss<<str3; ss>>n; triangle.bn =n-1; ss.clear(); ss<<str2; ss>>n; ss.clear(); triangle.btc = n-1; in>>str; pos = str.find(delimeter); str1 = str.substr(0,pos); str2 = str.substr(pos+delimeter.length()); pos = str2.find(delimeter); str3 = str2.substr(pos+delimeter.length()); str2 = str2.substr(0,pos); ss<<str1; ss>>n; triangle.c= n-1; ss.clear(); ss<<str3; ss>>n; triangle.cn =n-1; ss.clear(); ss<<str2; ss>>n; ss.clear(); triangle.ctc = n-1; triangles.push_back(triangle); } cmd = ""; } in.close(); return true; } return false; Code to draw model: glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glBindTexture(GL_TEXTURE_2D,image); glBegin(GL_TRIANGLES); for(int i=0;i<triangles.size();i++) { glTexCoord2f(texcords[triangles[i].ctc].x, texcords[triangles[i].ctc].y); glNormal3f(normals[triangles[i].cn].x, normals[triangles[i].cn].y, normals[triangles[i].cn].z); glVertex3f( points[triangles[i].c].x, points[triangles[i].c].y, points[triangles[i].c].z); glTexCoord2f(texcords[triangles[i].btc].x, texcords[triangles[i].btc].y); glNormal3f(normals[triangles[i].bn].x, normals[triangles[i].bn].y, normals[triangles[i].bn].z); glVertex3f( points[triangles[i].b].x, points[triangles[i].b].y, points[triangles[i].b].z); glTexCoord2f(texcords[triangles[i].atc].x, texcords[triangles[i].atc].y); glNormal3f(normals[triangles[i].an].x, normals[triangles[i].an].y, normals[triangles[i].an].z); glVertex3f( points[triangles[i].a].x, points[triangles[i].a].y, points[triangles[i].a].z); } glEnd(); glDisable(GL_TEXTURE_2D); Mayby someone find mistake in this

    Read the article

  • SQL Split function that handles string with delimeter appearing between text qualifiers?

    - by Ron
    There are several SQL split functions, from loop driven, to using xml commands, and even using a numbers table. I haven't found one that supports text qualifiers. Using the example string below, I would like to split on ",", but not when it appears between double or single quotes. Example data: [email protected], "Sally \"Heat\" Jones" <[email protected]>, "Mark Jones" <[email protected]>, "Stone, Ron" <[email protected]> Should return a table: [email protected] "Sally \"Heat\" Jones" <[email protected]> "Mark Jones" <[email protected]> "Stone, Ron" <[email protected]> I know this is a complex query/function, but any suggestions or any guidance would be mucho appreciated.

    Read the article

  • Uploading and Importing CSV file to SQL Server in ASP.NET WebForms

    - by Vincent Maverick Durano
    Few weeks ago I was working with a small internal project  that involves importing CSV file to Sql Server database and thought I'd share the simple implementation that I did on the project. In this post I will demonstrate how to upload and import CSV file to SQL Server database. As some may have already know, importing CSV file to SQL Server is easy and simple but difficulties arise when the CSV file contains, many columns with different data types. Basically, the provider cannot differentiate data types between the columns or the rows, blindly it will consider them as a data type based on first few rows and leave all the data which does not match the data type. To overcome this problem, I used schema.ini file to define the data type of the CSV file and allow the provider to read that and recognize the exact data types of each column. Now what is schema.ini? Taken from the documentation: The Schema.ini is a information file, used to define the data structure and format of each column that contains data in the CSV file. If schema.ini file exists in the directory, Microsoft.Jet.OLEDB provider automatically reads it and recognizes the data type information of each column in the CSV file. Thus, the provider intelligently avoids the misinterpretation of data types before inserting the data into the database. For more information see: http://msdn.microsoft.com/en-us/library/ms709353%28VS.85%29.aspx Points to remember before creating schema.ini:   1. The schema information file, must always named as 'schema.ini'.   2. The schema.ini file must be kept in the same directory where the CSV file exists.   3. The schema.ini file must be created before reading the CSV file.   4. The first line of the schema.ini, must the name of the CSV file, followed by the properties of the CSV file, and then the properties of the each column in the CSV file. Here's an example of how the schema looked like: [Employee.csv] ColNameHeader=False Format=CSVDelimited DateTimeFormat=dd-MMM-yyyy Col1=EmployeeID Long Col2=EmployeeFirstName Text Width 100 Col3=EmployeeLastName Text Width 50 Col4=EmployeeEmailAddress Text Width 50 To get started lets's go a head and create a simple blank database. Just for the purpose of this demo I created a database called TestDB. After creating the database then lets go a head and fire up Visual Studio and then create a new WebApplication project. Under the root application create a folder called UploadedCSVFiles and then place the schema.ini on that folder. The uploaded CSV files will be stored in this folder after the user imports the file. Now add a WebForm in the project and set up the HTML mark up and add one (1) FileUpload control one(1)Button and three (3) Label controls. After that we can now proceed with the codes for uploading and importing the CSV file to SQL Server database. Here are the full code blocks below: 1: using System; 2: using System.Data; 3: using System.Data.SqlClient; 4: using System.Data.OleDb; 5: using System.IO; 6: using System.Text; 7:   8: namespace WebApplication1 9: { 10: public partial class CSVToSQLImporting : System.Web.UI.Page 11: { 12: private string GetConnectionString() 13: { 14: return System.Configuration.ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString; 15: } 16: private void CreateDatabaseTable(DataTable dt, string tableName) 17: { 18:   19: string sqlQuery = string.Empty; 20: string sqlDBType = string.Empty; 21: string dataType = string.Empty; 22: int maxLength = 0; 23: StringBuilder sb = new StringBuilder(); 24:   25: sb.AppendFormat(string.Format("CREATE TABLE {0} (", tableName)); 26:   27: for (int i = 0; i < dt.Columns.Count; i++) 28: { 29: dataType = dt.Columns[i].DataType.ToString(); 30: if (dataType == "System.Int32") 31: { 32: sqlDBType = "INT"; 33: } 34: else if (dataType == "System.String") 35: { 36: sqlDBType = "NVARCHAR"; 37: maxLength = dt.Columns[i].MaxLength; 38: } 39:   40: if (maxLength > 0) 41: { 42: sb.AppendFormat(string.Format(" {0} {1} ({2}), ", dt.Columns[i].ColumnName, sqlDBType, maxLength)); 43: } 44: else 45: { 46: sb.AppendFormat(string.Format(" {0} {1}, ", dt.Columns[i].ColumnName, sqlDBType)); 47: } 48: } 49:   50: sqlQuery = sb.ToString(); 51: sqlQuery = sqlQuery.Trim().TrimEnd(','); 52: sqlQuery = sqlQuery + " )"; 53:   54: using (SqlConnection sqlConn = new SqlConnection(GetConnectionString())) 55: { 56: sqlConn.Open(); 57: SqlCommand sqlCmd = new SqlCommand(sqlQuery, sqlConn); 58: sqlCmd.ExecuteNonQuery(); 59: sqlConn.Close(); 60: } 61:   62: } 63: private void LoadDataToDatabase(string tableName, string fileFullPath, string delimeter) 64: { 65: string sqlQuery = string.Empty; 66: StringBuilder sb = new StringBuilder(); 67:   68: sb.AppendFormat(string.Format("BULK INSERT {0} ", tableName)); 69: sb.AppendFormat(string.Format(" FROM '{0}'", fileFullPath)); 70: sb.AppendFormat(string.Format(" WITH ( FIELDTERMINATOR = '{0}' , ROWTERMINATOR = '\n' )", delimeter)); 71:   72: sqlQuery = sb.ToString(); 73:   74: using (SqlConnection sqlConn = new SqlConnection(GetConnectionString())) 75: { 76: sqlConn.Open(); 77: SqlCommand sqlCmd = new SqlCommand(sqlQuery, sqlConn); 78: sqlCmd.ExecuteNonQuery(); 79: sqlConn.Close(); 80: } 81: } 82: protected void Page_Load(object sender, EventArgs e) 83: { 84:   85: } 86: protected void BTNImport_Click(object sender, EventArgs e) 87: { 88: if (FileUpload1.HasFile) 89: { 90: FileInfo fileInfo = new FileInfo(FileUpload1.PostedFile.FileName); 91: if (fileInfo.Name.Contains(".csv")) 92: { 93:   94: string fileName = fileInfo.Name.Replace(".csv", "").ToString(); 95: string csvFilePath = Server.MapPath("UploadedCSVFiles") + "\\" + fileInfo.Name; 96:   97: //Save the CSV file in the Server inside 'MyCSVFolder' 98: FileUpload1.SaveAs(csvFilePath); 99:   100: //Fetch the location of CSV file 101: string filePath = Server.MapPath("UploadedCSVFiles") + "\\"; 102: string strSql = "SELECT * FROM [" + fileInfo.Name + "]"; 103: string strCSVConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";" + "Extended Properties='text;HDR=YES;'"; 104:   105: // load the data from CSV to DataTable 106:   107: OleDbDataAdapter adapter = new OleDbDataAdapter(strSql, strCSVConnString); 108: DataTable dtCSV = new DataTable(); 109: DataTable dtSchema = new DataTable(); 110:   111: adapter.FillSchema(dtCSV, SchemaType.Mapped); 112: adapter.Fill(dtCSV); 113:   114: if (dtCSV.Rows.Count > 0) 115: { 116: CreateDatabaseTable(dtCSV, fileName); 117: Label2.Text = string.Format("The table ({0}) has been successfully created to the database.", fileName); 118:   119: string fileFullPath = filePath + fileInfo.Name; 120: LoadDataToDatabase(fileName, fileFullPath, ","); 121:   122: Label1.Text = string.Format("({0}) records has been loaded to the table {1}.", dtCSV.Rows.Count, fileName); 123: } 124: else 125: { 126: LBLError.Text = "File is empty."; 127: } 128: } 129: else 130: { 131: LBLError.Text = "Unable to recognize file."; 132: } 133:   134: } 135: } 136: } 137: } The code above consists of three (3) private methods which are the GetConnectionString(), CreateDatabaseTable() and LoadDataToDatabase(). The GetConnectionString() is a method that returns a string. This method basically gets the connection string that is configured in the web.config file. The CreateDatabaseTable() is method that accepts two (2) parameters which are the DataTable and the filename. As the method name already suggested, this method automatically create a Table to the database based on the source DataTable and the filename of the CSV file. The LoadDataToDatabase() is a method that accepts three (3) parameters which are the tableName, fileFullPath and delimeter value. This method is where the actual saving or importing of data from CSV to SQL server happend. The codes at BTNImport_Click event handles the uploading of CSV file to the specified location and at the same time this is where the CreateDatabaseTable() and LoadDataToDatabase() are being called. If you notice I also added some basic trappings and validations within that event. Now to test the importing utility then let's create a simple data in a CSV format. Just for the simplicity of this demo let's create a CSV file and name it as "Employee" and add some data on it. Here's an example below: 1,VMS,Durano,[email protected] 2,Jennifer,Cortes,[email protected] 3,Xhaiden,Durano,[email protected] 4,Angel,Santos,[email protected] 5,Kier,Binks,[email protected] 6,Erika,Bird,[email protected] 7,Vianne,Durano,[email protected] 8,Lilibeth,Tree,[email protected] 9,Bon,Bolger,[email protected] 10,Brian,Jones,[email protected] Now save the newly created CSV file in some location in your hard drive. Okay let's run the application and browse the CSV file that we have just created. Take a look at the sample screen shots below: After browsing the CSV file. After clicking the Import Button Now if we look at the database that we have created earlier you'll notice that the Employee table is created with the imported data on it. See below screen shot.   That's it! I hope someone find this post useful! Technorati Tags: ASP.NET,CSV,SQL,C#,ADO.NET

    Read the article

  • Parsing pipe delimited string into columns?

    - by DMS
    Hello, I have a column with pipe separated values such as: '23|12.1| 450|30|9|78|82.5|92.1|120|185|52|11' I want to parse this column to fill a table with 12 corresponding columns: month1, month2, month3...month12. So month1 will have the value 23, month2 the value 12.1 etc... Is there a way to parse it by a loop or delimeter instead of having to separate one value at a time using substr? Thanks.

    Read the article

  • Unit Testing a CSV Parser and Column Mapping Tool

    - by PieterG
    I am really starting to enjoy unit testing and have the following question to the gurus of unit testing. Let's for example say I have the following class public class FileMapper { public Dictionary<string, string> ReadFile(string filename, string delimeter){} } How do you guys generally go about unit testing a Parser or ReadFile method in my case?

    Read the article

  • elilo commandline boot config that includes spaces

    - by qdot
    I've got an elilo (EFI LILO) config file that includes spaces in the label - like that: image=/EFI/gentoo/boot/kernel-genkernel-ia64-3.1.6-gentoo label="Gentoo IA64 3.1.6" append="real_root=/dev/sda2" initrd=/EFI/gentoo/boot/initramfs-genkernel-ia64-3.1.6-gentoo read-only How can I select this label from ELILO's command line - the usual suspects: Gentoo IA64 3.1.6 "Gentoo IA64 3.1.6" 'Gentoo IA64 3.1.6' Gentoo\ IA64\ 3.1.6 all fail with the Kernel file not found Gentoo/"Gentoo/'Gentoo/Gentoo\" kind of error. Surely there must be a way to use a 'space' without making it a parameter delimeter?

    Read the article

  • Importing CSV files into Excel using a macro

    - by B-Ballerl
    I'm want to develop a macro where in my excel worksheet I type a date in a specific cell, and the macro will go into a folder containing text files. A database you could say. I want it to find the corresponding file name which is written as a date, put the data through a delimeter, and paste into the cells directly below where I orginally put the date. I'm very new with Macro's so if you must answer try to be a little more simple than you might usually be. Thanks In Advance if anyone can Help!! Update The folder will always be in the same place and the text files will all be formatted DD_MM_YYYY. And there cells below will always be empty Some Pictures to Make what I'm asking, easier to figure out. View the Image in a new tab for better res.

    Read the article

  • Excel Macro Help - Data Input

    - by B-Ballerl
    I'm want to develop a macro where in my excel worksheet I type a date in a specific cell, and the macro will go into a folder containing text files. A database you could say. I want it to find the corresponding file name which is written as a date, put the data through a delimeter, and paste into the cells directly below where I orginally put the date. I'm very new with Macro's so if you must answer try to be a little more simple than you might usually be. Thanks In Advance if anyone can Help!!

    Read the article

  • string parse and replace in for loop

    - by reffer
    i have a string that looks like this - "1AL||9CA||34CO||196WY||..." i want to use a for loop or while loop, in which if i have an integer, it should parse this string and delete the value matching that integer. example for above string string = "1AL||9CA||34CO||196WY||..." integer = 34 for ... loop new string = "1AL||9CA||196WY||..." As you can see the integer matched the integer 34 and deleted from one delimeter "||" to th next one. how can i do this?

    Read the article

  • problem using getline with a unicode file

    - by hamishmcn
    UPDATE: Thank you to @Potatoswatter and @Jonathan Leffler for comments - rather embarrassingly I was caught out by the debugger tool tip not showing the value of a wstring correctly - however it still isn't quite working for me and I have updated the question below: If I have a small multibyte file I want to read into a string I use the following trick - I use getline with a delimeter of '\0' e.g. std::string contents_utf8; std::ifstream inf1("utf8.txt"); getline(inf1, contents_utf8, '\0'); This reads in the entire file including newlines. However if I try to do the same thing with a wide character file it doesn't work - my wstring only reads to the the first line. std::wstring contents_wide; std::wifstream inf2(L"ucs2-be.txt"); getline( inf2, contents_wide, wchar_t(0) ); //doesn't work For example my if unicode file contains the chars A and B seperated by CRLF, the hex looks like this: FE FF 00 41 00 0D 00 0A 00 42 Based on the fact that with a multibyte file getline with '\0' reads the entire file I believed that getline( inf2, contents_wide, wchar_t(0) ) should read in the entire unicode file. However it doesn't - with the example above my wide string would contain the following two wchar_ts: FF FF (If I remove the wchar_t(0) it reads in the first line as expected (ie FE FF 00 41 00 0D 00) Why doesn't wchar_t(0) work as a delimiting wchar_t of "00 00"? Thank you

    Read the article

  • How to write regex that searches for a dynamic amount of pairs?

    - by citronas
    Lets say a have a string such as this one: string txt = "Lore ipsum {{abc|prop1=\"asd\";prop2=\"bcd\";}} asd lore ipsum"; The information I want to extract "abc" and pairs like ("prop1","asd") , ("prop3", "bcd") where each pair used a ; as delimeter. Edit1: (based on MikeB's) code Ah, getting close. I found out how to parse the following: string txt = "Lore ipsum {{abc|prop1=\"asd\";prop2=\"http:///www.foo.com?foo=asd\";prop3=\"asd\";prop4=\"asd\";prop5=\"asd\";prop6=\"asd\";}} asd"; Regex r = new Regex("{{(?<single>([a-z0-9]*))\\|((?<pair>([a-z0-9]*=\"[a-z0-9.:/?=]*\";))*)}}", RegexOptions.Singleline | RegexOptions.IgnoreCase); Match m = r.Match(txt); if (m.Success) { Console.WriteLine(m.Groups["single"].Value); foreach (Capture cap in m.Groups["pair"].Captures) { Console.WriteLine(cap.Value); } } Question 1: How must I adjust the regex to say 'each value of a pair in delimited by \" only? I added chars like '.',';' etc, but I can't think of any char that I want to permit. The other way around would be much nicer. Question 2: How must I adjust this regex work with this thing here? string txt = "Lore ipsum {{abc|prop1=\"asd\";prop2=\"http:///www.foo.com?foo=asd\";prop3=\"asd\";prop4=\"asd\";prop5=\"asd\";prop6=\"asd\";}} asd lore ipsum {{aabc|prop1=\"asd\";prop2=\"http:///www.foo.com?foo=asd\";prop3=\"asd\";prop4=\"asd\";prop5=\"asd\";prop6=\"asd\";}}"; Therefore I'd probably try to get groups of {{...}} and use the other regex?

    Read the article

  • split string error in a compiled VB.NET class

    - by Andy Payne
    I'm having some trouble compiling some VB code I wrote to split a string based on a set of predefined delimeters (comma, semicolon, colon, etc). I have successfully written some code that can be loaded inside a custom VB component (I place this code inside a VB.NET component in a plug-in called Grasshopper) and everything works fine. For instance, let's say my incoming string is "123,456". When I feed this string into the VB code I wrote, I get a new list where the first value is "123" and the second value is "456". However, I have been trying to compile this code into it's own class so I can load it inside Grasshopper separately from the standard VB component. When I try to compile this code, it isn't separating the string into a new list with two values. Instead, I get a message that says "System.String []". Do you guys see anything wrong in my compile code? You can find an screenshot image of my problem at the following link: click to see image This is the VB code for the compiled class: Public Class SplitString Inherits GH_Component Public Sub New() MyBase.New("Split String", "Split", "Splits a string based on delimeters", "FireFly", "Serial") End Sub Public Overrides ReadOnly Property ComponentGuid() As System.Guid Get Return New Guid("3205caae-03a8-409d-8778-6b0f8971df52") End Get End Property Protected Overrides ReadOnly Property Internal_Icon_24x24() As System.Drawing.Bitmap Get Return My.Resources.icon_splitstring End Get End Property Protected Overrides Sub RegisterInputParams(ByVal pManager As Grasshopper.Kernel.GH_Component.GH_InputParamManager) pManager.Register_StringParam("String", "S", "Incoming string separated by a delimeter like a comma, semi-colon, colon, or forward slash", False) End Sub Protected Overrides Sub RegisterOutputParams(ByVal pManager As Grasshopper.Kernel.GH_Component.GH_OutputParamManager) pManager.Register_StringParam("Tokenized Output", "O", "Tokenized Output") End Sub Protected Overrides Sub SolveInstance(ByVal DA As Grasshopper.Kernel.IGH_DataAccess) Dim myString As String DA.GetData(0, myString) myString = myString.Replace(",", "|") myString = myString.Replace(":", "|") myString = myString.Replace(";", "|") myString = myString.Replace("/", "|") myString = myString.Replace(")(", "|") myString = myString.Replace("(", String.Empty) myString = myString.Replace(")", String.Empty) Dim parts As String() = myString.Split("|"c) DA.SetData(0, parts) End Sub End Class This is the custom VB code I created inside Grasshopper: Private Sub RunScript(ByVal myString As String, ByRef A As Object) myString = myString.Replace(",", "|") myString = myString.Replace(":", "|") myString = myString.Replace(";", "|") myString = myString.Replace("/", "|") myString = myString.Replace(")(", "|") myString = myString.Replace("(", String.Empty) myString = myString.Replace(")", String.Empty) Dim parts As String() = myString.Split("|"c) A = parts End Sub ' ' End Class

    Read the article

  • TCP Message Structure with XML

    - by metdos
    Hello Everybody, I'm sending messages over TCP/IP and on the other side I parse TCP message.For example this is one of the sent messages. $DKMSG(requestType=REQUEST_LOGIN&requestId=123&username=metdos&password=123)$EDKMSG Clarification: $DKMSG( //Start )$EDKMSG //End requestType //Parameter REQUEST_LOGIN //Parameter Value Now I also want to add an Xml file to my message. I'm considering this option: $DKMSG(requestType=REQUEST_LOGIN&xmlData= <Item id="56D@MIT" type="SIGNAL"> <Label> <Text>56D</Text> <X1>10</X1> <Y1>40</Y1> <RotateAngle>90</RotateAngle> </Label> <X1>0</X1> <Y1>20</Y1> <Width>35</Width> <Height>10</Height> <Source>sgs3lr</Source> </Item> )$EDKMSG There are problems with this way: 1-)It doesn't seem right to me. 2-)I have to handle delimeter "=" with much more care or I need to change it in parameters. What are your suggestions, thanks.

    Read the article

  • Creating and parsing huge strings with javascript?

    - by user246114
    Hi, I have a simple piece of data that I'm storing on a server, as a plain string. It is kind of ridiculous, but it looks like this: name|date|grade|description|name|date|grade|description|repeat for a long time this string can be up to 1.4mb in size. The idea is that it's a bunch of student records, just strung together with a simple pipe delimeter. It's a very poor serialization method. Once this massive string is pushed to the client, it is split along the pipes into student records again, using javascript. I've been timing how long it takes to create, and split, these strings on the client side. The times are actually quite good, the slowest run I've seen on a few different machines is 0.2 seconds for 10,000 'student records', which has a final string size of ~1.4mb. I realize this is quite bizarre, just wondering if there are any inherent problems with creating and splitting such large strings using javascript? I don't know how different browsers implement their javascript engines. I've tried this on the 'major' browsers, but don't know how this would perform on earlier versions of each. Yeah looking for any comments on this, this is more for fun than anything else! Thanks

    Read the article

  • android error NoSuchElementException

    - by Alexander
    I have returned a cursor string but it contains a delimiter. The delimiter is . I have the string quest.setText(String.valueOf(c.getString(1)));I want to turn the into a new line. What is the best method to achieve this task in android. I understand there is a way to get the delimeter. I want this to achieved for each record. I can itterate through record like so. Cursor c = db.getContact(2); I tried using a string tokenizer but it doesnt seem to work. Here is the code for the tokenizer. I tested it in just plain java and it works without errors. String question = c.getString(1); // quest.setText(String.valueOf(c.getString(1))); //quest.setText(String.valueOf(question)); StringTokenizer st = new StringTokenizer(question,"<ENTER>"); //DisplayContact(c); // StringTokenizer st = new StringTokenizer(question, "=<ENTER>"); while(st.hasMoreTokens()) { String key = st.nextToken(); String val = st.nextToken(); System.out.println(key + "\n" + val); } I then tried running it in android. Here is the error log 06-06 22:31:55.251: E/AndroidRuntime(537): FATAL EXCEPTION: main 06-06 22:31:55.251: E/AndroidRuntime(537): java.util.NoSuchElementException 06-06 22:31:55.251: E/AndroidRuntime(537): at java.util.StringTokenizer.nextToken(StringTokenizer.java:208) 06-06 22:31:55.251: E/AndroidRuntime(537): at alex.android.test.database.quiz.TestdatabasequizActivity$1.onClick(TestdatabasequizActivity.java:95) 06-06 22:31:55.251: E/AndroidRuntime(537): at android.view.View.performClick(View.java:3511) 06-06 22:31:55.251: E/AndroidRuntime(537): at android.view.View$PerformClick.run(View.java:14105) 06-06 22:31:55.251: E/AndroidRuntime(537): at android.os.Handler.handleCallback(Handler.java:605) 06-06 22:31:55.251: E/AndroidRuntime(537): at android.os.Handler.dispatchMessage(Handler.java:92) 06-06 22:31:55.251: E/AndroidRuntime(537): at android.os.Looper.loop(Looper.java:137) 06-06 22:31:55.251: E/AndroidRuntime(537): at android.app.ActivityThread.main(ActivityThread.java:4424) 06-06 22:31:55.251: E/AndroidRuntime(537): at java.lang.reflect.Method.invokeNative(Native Method) 06-06 22:31:55.251: E/AndroidRuntime(537): at java.lang.reflect.Method.invoke(Method.java:511) 06-06 22:31:55.251: E/AndroidRuntime(537): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 06-06 22:31:55.251: E/AndroidRuntime(537): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 06-06 22:31:55.251: E/AndroidRuntime(537): at dalvik.system.NativeStart.main(Native Method) This is the database query public Cursor getContact(long rowId) throws SQLException { Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, question, possibleAnsOne,possibleAnsTwo, possibleAnsThree,realQuestion,UR}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); }

    Read the article

1