I have strings representing an angle, of the format ddd°mm'ss''. I want to get to the three constituents: degrees, minutes and seconds. I first chopped off the seconds like this: `angleString = “ddd°mm'ss''”;` `string str = angleString.Substring(0, angleString.Length - 2);` Then I tried to do this, to get to the degrees,minutes and seconds: `string[] items = str.Split(new char[] { '°', '''});` But it gave an error on the ' character, saying: "empty char literal". I solved by using this: `string[] items = str.Split(new char[] { '°', char.Parse("'") });` I find this rather clumsy. It would be great if anyone over …

Member Avatar
Member Avatar
+0 forum 3

I am using PHP Simple HTML DOM Parser to fetch urls, but i got an error while fetching links. Have a look at this script: $result = str_get_html($result); foreach($result->find('a') as $element) $result = str_get_html($result); $result = str_replace('http://', '', $result); foreach($result->find('a') as $elementa) echo $element->href; echo $elementa->href; Here I want to fetch all links for twice, first time urls in `$element->href` will fetch links starting with `http://` and in `$elementa->href` will fetch links without `http://` But this shows only a blank page. Any idea?

Member Avatar
Member Avatar
+0 forum 9

Hello, I recently took a course on assembler/compiler construction. In it we covered parsing algorithms such as LL(n), LR(n), LALR(n), and SLR(n). I understand how these parsing algorithms can be used to determine **if** an input string follows a context free grammar (CFG). At some point I also understood how to tokenize the string using the grammar, however my assignment code is not commented (in hindsight that was a mistake) and I do not understand it anymore. Now I am in need of a parser to convert lines of code into useful tokens and cannot for the life of me …

Member Avatar
Member Avatar
+0 forum 3

All, What is the most efficient way of writing several lines of data to a *.txt file? Currently, I store the required text in memory then write it all to a user-specified text file at the end, similar to the following; Dim text As String = "" text = text + "1st line of text" & vbNewLine text = text + "2nd line of text" & vbNewLine text = text + "3rd line of text" & vbNewLine Dim path As String = "C:\Temp\fileName.txt" My.Computer.FileSystem.WriteAllText(path, text, True, System.Text.Encoding.Default) This works well enough for up to about 1000 lines of text. However, …

Member Avatar
Member Avatar
+0 forum 5

I have a large data set (12,000 rows X 14 columns); the first 4 rows as below: x1 y1 0.02 NAN NAN NAN NAN NAN NAN 0.004 NAN NAN NAN NAN x2 y2 NAN 0.003 NAN 10 NAN 0.03 NAN 0.004 NAN NAN NAN NAN x3 y3 NAN NAN NAN NAN NAN NAN NAN NAN NAN NAN NAN NAN x4 y4 NAN 0.004 NAN NAN NAN NAN 10 NAN NAN 30 NAN 0.004 I need to remove any row with "NAN" in columns 3-14 and then output the rest of the dataset. I wrote the following code: #!usr/bin/perl use warnings; …

Member Avatar
Member Avatar
+0 forum 4

I've been looking for a way to parse a simple XML-like language for use as a type of data storage. I've been through stuff like JSON, XML, etc but I don't want to use them because they are quite slow. I just need a simple way to parse this: [stuff] [key1]data[/key1] [key2]data[/key2] [/stuff] And make/map it into a dictionary, like this: {"stuff":{"key1":"data", "key2":"data"}} I've made myself a generator which will process a dictionary according to the syntax rules: def generate_di(self, item) assert type(item) is dict for key in item: if type(item[key]) is dict: self.puts(self.strtag % key) # means we are …

Member Avatar
Member Avatar
+0 forum 7

(edit) this is solved, was a unicode issue. Hi I'm hoping someone has used the library [pugixml](http://pugixml.org/) I'm just trying to use a simple example provided but I'm not getting the result I expect. int _tmain(int argc, _TCHAR* argv[]) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file("tree.xml"); //pugi::char_t * c = "Fail\0"; // used with as_string() method std::cout << "Load result: " << result.description() // output = "Load result: No Error " << ", mesh name: " << doc.child("mesh").attribute("name").value() // output = ", mesh name: " << std::endl; return 0; } I was expecting "Load result: No Error, mesh name: mesh_root" …

Member Avatar
+0 forum 0

Hi, I've just started out with Python and I've been stuck on this problem for a few hours now trying to parse a file into a certain format.. I am trying to create a list in a list out of a list. I currently have this list; ['MPNRRRCKLSTAISTVATLAIASPCAYFLVYEPTASAKPAAKHYEFKQAASIADLPGEVLDAISQGLSQFGINL', 'MQLVDRVRGAVTGMSRRLVVGAVGAALVSGLVGAVGGTATAGAFSRPGLPVEYLQVPSPSMGRSELPGWLQA', 'etc'] What I am trying to make is a list of each item, with the first 40 individual characters in the strings as items, while translating them into an int for example; M = 1.43, P=1.53, I want to be able to have each item as an individual list before putting …

Member Avatar
Member Avatar
+0 forum 2

Please can someone help me and send me in the right direction. I am making a program that reads a text file and then out puts the data into a datagrid, the text file looks like this: [HRData] 84 73 0 -124 0 50 84 73 0 -124 0 50 84 84 0 -124 0 50 87 109 0 -124 0 50 82 120 0 -124 0 50 82 132 0 -124 0 50 83 143 0 -124 0 50 83 154 0 -124 0 50 85 171 77 -124 0 50 86 179 84 -125 121 3893 87 190 …

Member Avatar
Member Avatar
+0 forum 1

Hi, I have quite a large CSV file (Around 20,000 rows with about 20 columns) that I am trying to manipulate. Initially I am looking for a way to get out the first 10 or so records after they have been sorted in ascending order on one of the numeric fields. I've thought of loading the file into memory and then sorting it from there using one of PHPs sort functions but as expected, the memory is simply exhausted. My current thoughts on this would be to read line by line attempting to place each record into an array (Which …

Member Avatar
Member Avatar
+0 forum 12

Hi, I've got a set of folders with each contain many files. I need to extract a specific file extention(.sof) from each of these folders to a new directory(or the same directory in a new folder). Any help is appreciated. Thanks.

Member Avatar
Member Avatar
+0 forum 4

Hi all, I've browsed the net trying to find a paradigm to describe what I'm looking for but haven't been successful. So I'll try to explain it as succinctly as I can. Right now, for my PhD research, I've set out a few applications that take input files that have paramater/value pairs. When I want to execute a specific case, I generate a new text file with the input parameters I want to pass to the application and execute the application using these parameters. Within the application, I read in the input file, strip and trim all unncessary stuff, like …

Member Avatar
Member Avatar
+0 forum 3

/*This code counts the vowels in strings? It has to use user defined methods: */ import java.lang.String; import java.io.*; import java.util.*; public class vowelConsonant2 { static Scanner scan = new Scanner(System.in); public static void main(String args[]) { String text; int actualI, actualC; System.out.println("Enter the String:"); text = scan.nextLine(); System.out.println("There are " + vowelcounter(actualI,actualC) + " vowels"); } public static int vowelcounter(int countv , int i , char c ) { countv = 0; for (int i = 0; i < text.length(); i++) { text = text.toLowerCase(); char c = text.charAt(i); if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') …

Member Avatar
Member Avatar
+0 forum 6

Hi, I want to process a text file. Here are the contents of the text file labels 1 -1 -1 0.2988 0.7012 -1 0.188161 0.811839 -1 0.0824541 0.917546 1 0.579515 0.420485 -1 0.0965063 0.903494 -1 0.174624 0.825376 -1 0.0404312 0.959569 -1 0.0770909 0.922909 -1 0.12001 0.87999 1 0.778388 0.221612 In the above data, there are 11 lines (rows) and 3 values (columns) are on each line and every value is separated by a space. The second are third column are actually the probability scores. Now I want to perform 2 actions. 1. I want to access the second column of …

Member Avatar
Member Avatar
+0 forum 3

hi, i would like to parse an input file (input.txt) into output file (output.txt) which i'll into excel. appreciate any advice on how to parse the input.txt into output.txt. thanks johnny

Member Avatar
Member Avatar
+0 forum 8

Hey, I have an website with dynamic text on it, i want to transfer the text to an textbox, and the text is between this tags: <pre> </pre> How do i do this?

Member Avatar
Member Avatar
+0 forum 11

Hi Guys, Another puzzle for someone to try and crack... I have two divs inside the <body> that basically act as two versions of the same page. I need PHP to call one based on a variable retrieved from a database. As it stands, this is what I have... [CODE] <?php session_start(); require("config.php"); if(!isset($_SESSION['username'])) { header('location:denied.php?msg=LOGIN REQUIRED'); } else { } $curruser = $_SESSION['username']; $con = mysql_connect("***","***","***"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("***", $con); $result = mysql_query("SELECT * FROM users WHERE username='" . $_SESSION['username']) . "'"; while($row = mysql_fetch_array($result)) { $version = $row['version']; $username = …

Member Avatar
Member Avatar
+0 forum 4

I want to parse command line arguments. Say someone gives me ./progname param2 [-price=50] [-size=10] [-weight=16] [-height=7] Square bracketed items are optional. Either none or exactly two of -price, -size, -weight, and -height can be specified. If none of them are specified, it should be taking default values for price & weight. I have already found how to decode for argv[0], argv[1]. But for argv[2] beyond till these optional items end, i am not able to parse. I require code that can help me or some sort of syntax if complete code not possible. Thanks.

Member Avatar
Member Avatar
+0 forum 2

I am using getline to read a CSV file. The line it reads looks something like "1/24/2010 6:19 1/24/2010 6:59 Merrill - Valley Farms yhy 69 Vegetation 55" The getline works but, I need to be able to calculate time days between a date the user inputs and the date here. AKA the first few characters in the line. I have tried to use assign and store them to arrays, which works great expect for sometimes the month is 1 or it could be 10, 11 or 12 and then assign does not work correctly. I have also tried strchr …

Member Avatar
Member Avatar
+0 forum 1

i have a program in c language that reads csv file.. now i want to read data column wise.. i want the whole program..which will take file name as command line argument and will fetch second column from the file.. lets assume file is like below.. aggromat,"1","abc","8903" aggromat,"2","abc","ddds" reply as soon as possible.

Member Avatar
Member Avatar
+0 forum 19

Hi all, Basically I am attempting to determine whether the first 2 columns (tab delimited file) from file1.txt match the first 2 columns of file2.txt. If they do I want to output the entire row of file1.txt to outputfile.txt... I can do this using vbs but due to the amount of data that this is going to have to trawl through it's not an option. Can anyone please help? Many thanks :)

Member Avatar
Member Avatar
+0 forum 9

Hi, I am looking for advice on the best way to achieve my current goal. I am reading a textfile and extracting information from each line. For example string1 and string2. I am then writing these string to a datatable. However, sometimes there will be repeats in string1 and string2. If there are repeated lines I would like to be able to delete the repeating line and add a counter to find the total number of repeating lines. so if a string repeates 3 times I would like there to be a column with a 3 displayed next to the …

Member Avatar
Member Avatar
+0 forum 3

Hello I am attempting to parse multiple lines of text from a text file using regexpressions. I am using vb.net with visual studio 2008. At the moment I am filling my datatable with the text file information and am able to return each line of text and parse the first set of numbers that I am attempting to break up. I have multiple string with varying lengths of character lengths and numeric lengths however the delimiters are sometimes different. Sometimes will be whitespace and sometimes will be whitespace and chars. But is always 2 spaces. Here is my code: [CODE] …

Member Avatar
Member Avatar
+0 forum 1

I need to do CSV parsing and I was wondering if this is possible with python and where I should go to learn how to code this script or get help. Let's say I have a CSV file with 20 rows and 4 columns. I need to: -Strip out the first five rows -Strip out the last three rows -Strip out the 2nd and 4th columns -Convert the dates in the 3rd column from format DD-MM-YYYY to MMM-DD (so for example, a 14-05-1999 gets converted to May-14) In the end, I'll have a CSV file with 12 rows and 2 …

Member Avatar
Member Avatar
+0 forum 4

I have a text file that looks like Y07976.1/124-271 Y07978.1/48-201 and I want to remove everything after the forward slash such that in the end the text file will look like Y07976.1 Y07978.1 I am currently learning perl and I think regular expressions are going to be a trouble for awhile but I thought about using [CODE] $line=~ s/\W.*//;[/CODE] but that removes everything after the "." and I want to keep the ".1". I appreciate any help. Thanks

Member Avatar
Member Avatar
+0 forum 2

I know that this is an easy one but it is hard for me to figure out. I need to make a program that can: * Open the file and read through all of the lines in the file. (got this) * If a line starts with "Subject:", skip the line. (got this) * For all the other lines, split the strings into a list of words using the white space and find the first word. After you have found the first word, split that string again into a *new* list of words using the "/" character. (got this I …

Member Avatar
Member Avatar
+0 forum 6

I have an API parsing script, which inserts into the db more than 40,000 rows.and maybe due large numbers of queries getting fired continuously, after some specific time the script throws "MySQL server has gone away" error. I know the reason behind this error can be closed connection or any other privileges on the mysql server. How should I deal with this error , so that i can execute the script completely.

Member Avatar
Member Avatar
+0 forum 4

Hi all, I'm learning python and hope someone can help me with a sort of tricky search/parse problem. I have a tab deliminited file like this: 2 1 863.8 300.2 0.0131 0.0759 0.1727 0.0879 1.5821 3 1 874.5 289.5 0.0574 0.1292 0.4447 0.2258 1.1846 3 2 874.5 289.5 0.0573 0.0527 1.0857 0.1684 1.1760 4 1 844.3 319.7 0.1306 1.3513 0.0967 1.3976 2.2659 4 2 849.2 314.8 0.1350 1.3332 0.1013 1.3773 1.9990 4 3 846.0 318.0 0.1546 1.4675 0.1053 1.5399 2.1172 2 :PAD_999) ... 1 :PAA_888) 3 :PAB_978) ... 1 :PAA_888) 4 :PCA_098) ... 1 :PAA_888) I would like to search …

Member Avatar
Member Avatar
+0 forum 7

The End.