Search Results

Search found 409 results on 17 pages for 'delimiter'.

Page 4/17 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • What is the modern eqivalent (C++) style for the older (C-like) fscanf method?

    - by Chris_45
    What is the best option if I want to "upgrade" old C-code to newer C++ when reading a file with a semicolon delimiter: /* reading in from file C-like: */ fscanf(tFile, "%d", &mypost.nr); /*delimiter ; */ fscanf(tFile, " ;%[^;];", mypost.aftername);/* delimiter ; */ fscanf(tFile, " %[^;]", mypost.forename); /*delimiter ; */ fscanf(tFile, " ;%[^;];", mypost.dept);/*delimiter ; */ fscanf(tFile, " %[^;];", mypost.position);/* delimiter ; */ fscanf(tFile, "%d", &mypost.nr2); //eqivalent best C++ method achieving the same thing?

    Read the article

  • What is the modern equivalent (C++) style for the older (C-like) fscanf method?

    - by Chris_45
    What is the best option if I want to "upgrade" old C-code to newer C++ when reading a file with a semicolon delimiter: /* reading in from file C-like: */ fscanf(tFile, "%d", &mypost.nr); /*delimiter ; */ fscanf(tFile, " ;%[^;];", mypost.aftername);/* delimiter ; */ fscanf(tFile, " %[^;]", mypost.forename); /*delimiter ; */ fscanf(tFile, " ;%[^;];", mypost.dept);/*delimiter ; */ fscanf(tFile, " %[^;];", mypost.position);/* delimiter ; */ fscanf(tFile, "%d", &mypost.nr2); //eqivalent best C++ method achieving the same thing?

    Read the article

  • What's the RegEx to make sure that delimiters are escaped?

    - by Kuyenda
    I'm looking for a regular expression that will check whether or not delimiters in a string are escaped with a backward slash. The delimiters I am concerned about are comma (\,), colon (\:), semicolon (\;) and of course the backward slash itself has to be escaped (\). For example, the string "test" should return a match because there are no delimiters in it, and no escaping is necessary. The string "te\;st" would return a match because the semicolon delimiter is escaped. "te;st" and "t\;s:t" would both fail because the both contain at least one delimiter that is not escaped. I know that I need a conditional and a positive look behind, and this is what I have so far, but it is not giving me the expected answer. ^(?<delimiter>[:;,\\])?(?(delimiter)\(?<=(?:\\\\)*\\)k<delimiter>|.)$ Any suggestions on how I can make this work? Thanks.

    Read the article

  • String update in SQL Server

    - by Thiyaneshwaran S
    Currently I have varchar field. The delimiter is "$P$P$". The delimiter will appear at least once and at most twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, I need to insert a text before the second occurance of the delimiter. Eg: Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion If the delimiter occurs only once, then I need to insert a text at the end of the field. Eg: Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE How this can be done in SQL query?

    Read the article

  • string update in sqlserver

    - by Thiyaneshwaran S
    Currently i have varchar field. The delimiter is "$P$P$". The delimiter will appear atleast once and atmost twice in the varchar data. Eg. Sample Heading$P$P$Sample description$P$P$Sample conclusion Sample Heading$P$P$Sample Description If the delimiter appears twice, i need to insert a text before the second occurance of the delimiter. Eg: Sample Heading$P$P$Sample DescriptionINSERT TEXT HERE$P$P$Sample Conclusion If the delimiter occurs only once, then i need to insert a text at the end of the field. Eg: Sample Heading$P$P$Sample DescriptionAPPEND TEXT HERE How this can be done in sql query?

    Read the article

  • How to refactor these generic methods?

    - by Steve Crane
    I have written two nearly identical generic extension methods and am trying to figure out how I might refactor them into a single method. They differ only in that one operates on List and the other on List, and the properties I'm interested in are AssetID for AssetDocument and PersonID for PersonDocument. Although AssetDocument and PersonDocument have the same base class the properties are defined in each class so I don't think that helps. I have tried public static string ToCSVList<T>(this T list) where T : List<PersonDocument>, List<AssetDocument> thinking I might then be able to test the type and act accordingly but this results in the syntax error Type parameter 'T' inherits conflicting constraints These are the methods that I would like to refactor into a single method but perhaps I am simply going overboard and they would besat be left as they are. I'd like to hear what you think. public static string ToCSVList<T>(this T list) where T : List<AssetDocument> { var sb = new StringBuilder(list.Count * 36 + list.Count); string delimiter = String.Empty; foreach (var document in list) { sb.Append(delimiter + document.AssetID.ToString()); delimiter = ","; } return sb.ToString(); } public static string ToCSVList<T>(this T list) where T : List<PersonDocument> { var sb = new StringBuilder(list.Count * 36 + list.Count); string delimiter = String.Empty; foreach (var document in list) { sb.Append(delimiter + document.PersonID.ToString()); delimiter = ","; } return sb.ToString(); }

    Read the article

  • Error in creating trigger using PHP script.. Please help!!!! Geeks

    - by Parth
    I've been successful in creating a simple trigger with a PHP script. The problem comes when I have to use "DELIMITER" in my trigger creating because I have nested if/then statements. For example, the following DOES work: $sql = 'CREATE TRIGGER `database`.`detail` BEFORE INSERT on `database`.`vibez_detail` FOR EACH ROW set @a=new.realtime_value'; $junk = mysqli_query($link, $sql); However, if I need to use "DELIMITER" I get errors galore. Here's what works if I go to the MySQL client at the server: DELIMITER $$; DROP TRIGGER `database`.`detail`$$ CREATE TRIGGER `database`.`detail` BEFORE INSERT on `database`.`vibez_detail` FOR EACH ROW BEGIN set new.data_rate = 69; insert into alarm_trips_parent values (null, new.data_rate, 6969, now()); set @tripped_time = now(); set @tripped:=true; end if; end if; END$$ DELIMITER ;$$ How can I construct the PHP code to get this to work? Seems the mysqli_query($link, $sql) chokes as soon as I put "DELIMITER" in the $sql variable. I get the following error when I attempt to do so: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER //; CREATE TRIGGER `database`.`detail` BEFORE INS' at line 1 Even The concept for using mysqli_multi_query(); didn't worked for me.... :(

    Read the article

  • Optimal way to generate list of PHP object properties with delimiter character, implode()?

    - by Kris
    I am trying to find out if there is a more optimal way for creating a list of an object's sub object's properties. (Apologies for the crude wording, I am not really much of an OO expert) I have an object "event" that has a collection of "artists", each artist having an "artist_name". On my HTML output, I want a plain list of artist names delimited by a comma. PHP's implode() seems to be the best way to create a comma delimited list of values. I am currently iterating through the object and push values in a temporary array "artistlist" so I can use implode(). That is the shortest I could come up with. Is there a way to do this more elegant? $artistlist = array(); foreach ($event->artists as $artist) { $artistlist[] = $artist->artist_name; } echo implode(', ', $artistlist);

    Read the article

  • Vim step-by-step: How do you line up arbitrary text by arbitrary delimiter?

    - by dreftymac
    Background: There are a lot of great tutorials and "tricks" pages for Vim, but one thing that is very difficult is to find specific instructions on how to do some arbitrary thing that one can easily do in one's own familiar text editor IDE. Therefore I am asking for step by step instructions on how you I would do something in Vim that I already know how to do in other text editors. I like Vim and the great built-in help and numerous on-line tutorials, but sometimes a human has to break down and ask another human. Question: Suppose I have the following code in my file, how can I use Vim to get from BEFORE, to AFTER? BEFORE: Lorem ipsum dolor | sit amet, consectetur | adipisicing elit, sed do eiusmod | tempor incididunt | ut labore et | dolore magna aliqua. | Ut enim ad minim veniam, quis nostrud | exercitation ullamco | laboris nisi ut | aliquip ex ea commodo | consequat. Duis aute irure AFTER: Lorem ipsum dolor | sit amet, consectetur | adipisicing elit, sed do eiusmod | tempor incididunt | ut labore et | dolore magna aliqua. | Ut enim ad minim veniam, quis nostrud | exercitation ullamco | laboris nisi ut | aliquip ex ea commodo | consequat. Duis aute irure

    Read the article

  • is there a way to designate the line token delimiter in Perl's file reader?

    - by Dr.Dredel
    I'm reading a text file via CGI in, in perl, and noticing that when the file is saved in mac's textEdit the line separator is recognized, but when I upload a CSV that is exported straight from excel, they are not. I'm guessing it's a \n vs. \r issue, but it got me thinking that I don't know how to specify what I would like the line terminator token to be, if I didn't want the one it's looking for by default.

    Read the article

  • How can I match everything in a string until the second occurrence of a delimiter with a regular expression?

    - by Steve
    I am trying to refine a preg_match_all by finding the second occurrence of a period then a space: <?php $str = "East Winds 20 knots. Gusts to 25 knots. Waters a moderate chop. Slight chance of showers."; preg_match_all ('/(^)((.|\n)+?)(\.\s{2})/',$str, $matches); $dataarray=$matches[2]; foreach ($dataarray as $value) { echo $value; } ?> But it does not work: the {2} occurrence is incorrect. I have to use preg_match_all because I am scraping dynamic HTML. I want to capture this from the string: East Winds 20 knots. Gusts to 25 knots.

    Read the article

  • Readline, the Input Record Separator and Ruby

    - by JustSmith
    In Ruby I'm looking to read data until I reach a delimiter or end of file. I found this is possible by redefining $/ or the $INPUT_RECORD_SEPARATOR to my delimiter. However with all the "features" in the Ruby language it seems hokey to change the value of a global to do this. Also, readline used to consume the delimiter while not it is included in what is returned. Is there any other way to "read until" while consuming the delimiter that doesn't involve getting the values char by char in a loop?

    Read the article

  • Copy results of strtok to 2 strings in C

    - by Mr. Man
    Ok, so I have the code char *token; char *delimiter = " "; token = strtok(command, delimiter); strcpy(command, token); token = strtok(NULL, delimiter); strcpy(arguments, token); and it gives me EXC_BAD_ACCESS when i run it, and yes, command and arguments are already defined.

    Read the article

  • Exploding by Array of Delimiters

    - by JoeC
    Is there any way to explode() using an array of delimiters? PHP Manual: array explode ( string $delimiter , string $string [, int $limit ] ) Instead of using string $delimiter is there any way to use array $delimiter without affecting performance too much?

    Read the article

  • How to compile a C++ source code written for Linux/Unix on Windows Vista (code given)

    - by HTMZ
    I have a c++ source code that was written in linux/unix environment by some other author. It gives me errors when i compile it in windows vista environment. I am using Bloodshed Dev C++ v 4.9. please help. #include <iostream.h> #include <map> #include <vector> #include <string> #include <string.h> #include <strstream> #include <unistd.h> #include <stdlib.h> using namespace std; template <class T> class PrefixSpan { private: vector < vector <T> > transaction; vector < pair <T, unsigned int> > pattern; unsigned int minsup; unsigned int minpat; unsigned int maxpat; bool all; bool where; string delimiter; bool verbose; ostream *os; void report (vector <pair <unsigned int, int> > &projected) { if (minpat > pattern.size()) return; // print where & pattern if (where) { *os << "<pattern>" << endl; // what: if (all) { *os << "<freq>" << pattern[pattern.size()-1].second << "</freq>" << endl; *os << "<what>"; for (unsigned int i = 0; i < pattern.size(); i++) *os << (i ? " " : "") << pattern[i].first; } else { *os << "<what>"; for (unsigned int i = 0; i < pattern.size(); i++) *os << (i ? " " : "") << pattern[i].first << delimiter << pattern[i].second; } *os << "</what>" << endl; // where *os << "<where>"; for (unsigned int i = 0; i < projected.size(); i++) *os << (i ? " " : "") << projected[i].first; *os << "</where>" << endl; *os << "</pattern>" << endl; } else { // print found pattern only if (all) { *os << pattern[pattern.size()-1].second; for (unsigned int i = 0; i < pattern.size(); i++) *os << " " << pattern[i].first; } else { for (unsigned int i = 0; i < pattern.size(); i++) *os << (i ? " " : "") << pattern[i].first << delimiter << pattern[i].second; } *os << endl; } } void project (vector <pair <unsigned int, int> > &projected) { if (all) report(projected); map <T, vector <pair <unsigned int, int> > > counter; for (unsigned int i = 0; i < projected.size(); i++) { int pos = projected[i].second; unsigned int id = projected[i].first; unsigned int size = transaction[id].size(); map <T, int> tmp; for (unsigned int j = pos + 1; j < size; j++) { T item = transaction[id][j]; if (tmp.find (item) == tmp.end()) tmp[item] = j ; } for (map <T, int>::iterator k = tmp.begin(); k != tmp.end(); ++k) counter[k->first].push_back (make_pair <unsigned int, int> (id, k->second)); } for (map <T, vector <pair <unsigned int, int> > >::iterator l = counter.begin (); l != counter.end (); ) { if (l->second.size() < minsup) { map <T, vector <pair <unsigned int, int> > >::iterator tmp = l; tmp = l; ++tmp; counter.erase (l); l = tmp; } else { ++l; } } if (! all && counter.size () == 0) { report (projected); return; } for (map <T, vector <pair <unsigned int, int> > >::iterator l = counter.begin (); l != counter.end(); ++l) { if (pattern.size () < maxpat) { pattern.push_back (make_pair <T, unsigned int> (l->first, l->second.size())); project (l->second); pattern.erase (pattern.end()); } } } public: PrefixSpan (unsigned int _minsup = 1, unsigned int _minpat = 1, unsigned int _maxpat = 0xffffffff, bool _all = false, bool _where = false, string _delimiter = "/", bool _verbose = false): minsup(_minsup), minpat (_minpat), maxpat (_maxpat), all(_all), where(_where), delimiter (_delimiter), verbose (_verbose) {}; ~PrefixSpan () {}; istream& read (istream &is) { string line; vector <T> tmp; T item; while (getline (is, line)) { tmp.clear (); istrstream istrs ((char *)line.c_str()); while (istrs >> item) tmp.push_back (item); transaction.push_back (tmp); } return is; } ostream& run (ostream &_os) { os = &_os; if (verbose) *os << transaction.size() << endl; vector <pair <unsigned int, int> > root; for (unsigned int i = 0; i < transaction.size(); i++) root.push_back (make_pair (i, -1)); project (root); return *os; } void clear () { transaction.clear (); pattern.clear (); } }; int main (int argc, char **argv) { extern char *optarg; unsigned int minsup = 1; unsigned int minpat = 1; unsigned int maxpat = 0xffffffff; bool all = false; bool where = false; string delimiter = "/"; bool verbose = false; string type = "string"; int opt; while ((opt = getopt(argc, argv, "awvt:M:m:L:d:")) != -1) { switch(opt) { case 'a': all = true; break; case 'w': where = true; break; case 'v': verbose = true; break; case 'm': minsup = atoi (optarg); break; case 'M': minpat = atoi (optarg); break; case 'L': maxpat = atoi (optarg); break; case 't': type = string (optarg); break; case 'd': delimiter = string (optarg); break; default: cout << "Usage: " << argv[0] << " [-m minsup] [-M minpat] [-L maxpat] [-a] [-w] [-v] [-t type] [-d delimiter] < data .." << endl; return -1; } } if (type == "int") { PrefixSpan<unsigned int> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); }else if (type == "short") { PrefixSpan<unsigned short> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); } else if (type == "char") { PrefixSpan<unsigned char> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); } else if (type == "string") { PrefixSpan<string> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose); prefixspan.read (cin); prefixspan.run (cout); } else { cerr << "Unknown Item Type: " << type << " : choose from [string|int|short|char]" << endl; return -1; } return 0; }

    Read the article

  • how to solve syntax error in procedure in mysql?

    - by Shooter
    Hi all, i am executing a procedure in mysql, procedure is- delimiter $$ create procedure getFacility (in id int, out MyFacility VARCHAR(200)) begin select Facility into MyFacility from facilities where FacilityID = id ; end $$ delimiter ; and it is giving error below- Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'end $$ delimiter' at line 1 (0 ms taken) how to solve this error? Thanks, Yugal

    Read the article

  • Unrealscript splitting a string

    - by burntsugar
    Note, this is repost from stackoverflow - I have only just discovered this site :) I need to split a string in Unrealscript, in the same way that Java's split function works. For instance - return the string "foo" as an array of char. I have tried to use the SplitString function: array SplitString( string Source, optional string Delimiter=",", optional bool bCullEmpty ) Wrapper for splitting a string into an array of strings using a single expression. as found at http://udn.epicgames.com/Three/UnrealScriptFunctions.html but it returns the entire String. simulated function wordDraw() { local String inputString; inputString = "trolls"; local string whatwillitbe; local int b; local int x; local array<String> letterArray; letterArray = SplitString(inputString,, false); for (x = 0; x < letterArray.Length; x++) { whatwillitbe = letterArray[x]; `log('it will be '@whatwillitbe); b = letterarray.Length; `log('letterarray length is '@b); `log('letter number '@x); } } Output is: b returns: 1 whatwillitbe returns: trolls However I would like b to return 6 and whatwillitbe to return each character individually. I have had a few answers proposed, however, I would still like to properly understand how the SplitString function works. For instance, if the Delimiter parameter is optional, what does the function use as a delimiter by default?

    Read the article

  • How to remove the last character from Stringbuilder

    - by hmloo
    We usually use StringBuilder to append string in loops and make a string of each data separated by a delimiter. but you always end up with an extra delimiter at the end. This code sample shows how to remove the last delimiter from a StringBuilder. using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { static void Main() { var list =Enumerable.Range(0, 10).ToArray(); StringBuilder sb = new StringBuilder(); foreach(var item in list) { sb.Append(item).Append(","); } sb.Length--;//Just reduce the length of StringBuilder, it's so easy Console.WriteLine(sb); } } //Output : 0,1,2,3,4,5,6,7,8,9 Alternatively,  we can use string.Join for the same results, please refer to blow code sample. using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { static void Main() { var list = Enumerable.Range(0, 10).Select(n => n.ToString()).ToArray(); string str = string.Join(",", list); Console.WriteLine(str); } }

    Read the article

  • CLR: Multi Param Aggregate, Argument not in Final Output?

    - by OMG Ponies
    Why is my delimiter not appearing in the final output? It's initialized to be a comma, but I only get ~5 white spaces between each attribute using: SELECT [article_id] , dbo.GROUP_CONCAT(0, t.tag_name, ',') AS col FROM [AdventureWorks].[dbo].[ARTICLE_TAG_XREF] atx JOIN [AdventureWorks].[dbo].[TAGS] t ON t.tag_id = atx.tag_id GROUP BY article_id The bit for DISTINCT works fine, but it operates within the Accumulate scope... Output: article_id | col ------------------------------------------------- 1 | a a b c I only have rudimentary C# API knowledge... C# Code: using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; using System.Xml.Serialization; using System.Xml; using System.IO; using System.Collections; using System.Text; [Serializable] [SqlUserDefinedAggregate(Format.UserDefined, MaxByteSize = 8000)] public struct GROUP_CONCAT : IBinarySerialize { ArrayList list; string delimiter; public void Init() { list = new ArrayList(); delimiter = ","; } public void Accumulate(SqlBoolean isDistinct, SqlString Value, SqlString separator) { delimiter = (separator.IsNull) ? "," : separator.Value ; if (!Value.IsNull) { if (isDistinct) { if (!list.Contains(Value.Value)) { list.Add(Value.Value); } } else { list.Add(Value.Value); } } } public void Merge(GROUP_CONCAT Group) { list.AddRange(Group.list); } public SqlString Terminate() { string[] strings = new string[list.Count]; for (int i = 0; i < list.Count; i++) { strings[i] = list[i].ToString(); } return new SqlString(string.Join(delimiter, strings)); } #region IBinarySerialize Members public void Read(BinaryReader r) { int itemCount = r.ReadInt32(); list = new ArrayList(itemCount); for (int i = 0; i < itemCount; i++) { this.list.Add(r.ReadString()); } } public void Write(BinaryWriter w) { w.Write(list.Count); foreach (string s in list) { w.Write(s); } } #endregion }

    Read the article

  • Specifying formatting for csv.writer in Python

    - by user248237
    I am using csv.DictWriter to output csv files from a set of dictionaries. I use the following function: def dictlist2file(dictrows, filename, fieldnames, delimiter='\t', lineterminator='\n'): out_f = open(filename, 'w') # Write out header header = delimiter.join(fieldnames) + lineterminator out_f.write(header) # Write out dictionary data = csv.DictWriter(out_f, fieldnames, delimiter=delimiter, lineterminator=lineterminator) data.writerows(dictrows) out_f.close() where dictrows is a list of dictionaries, and fieldnames provides the headers that should be serialized to file. Some of the values in my dictionary list (dictrows) are numeric -- e.g. floats, and I'd like to specify the formatting of these. For example, I might want floats to be serialized with "%.2f" rather than full precision. Ideally, I'd like to specify some kind of mapping that says how to format each type, e.g. {float: "%.2f"} that says that if you see a float, format it with %.2f. Is there an easy way to do this? I don't want to subclass DictWriter or anything complicated like that -- this seems like very generic functionality. How can this be done? The only other solution I can think of is: instead of messing with the formatting of DictWriter, just use the decimal package to specify the decimal precision of floats to be %.2 which will cause to be serialized as such. Don't know if this is a better solution? thanks very much for your help.

    Read the article

  • Stored procedure strange error when called through php

    - by ravi
    I have been coding a registration page(login system) in php and mysql for a website. I'm using two stored procedures for the same. First stored procedure checks wether the email address already exists in database.Second one inserts the user supplied data into mysql database. User has EXECUTE permission on both the procedures.When is execute them individually from php script they work fine. But when i use them together in script second Stored procedure(insert) not working. Stored procedure 1. DELIMITER $$ CREATE PROCEDURE reg_check_email(email VARCHAR(80)) BEGIN SET @email = email; SET @sql = 'SELECT email FROM user_account WHERE user_account.email=?'; PREPARE stmt FROM @sql; EXECUTE stmt USING @email; END$$ DELIMITER; Stored procedure 2 DELIMITER $$ CREATE PROCEDURE reg_insert_into_db(fname VARCHAR(40), lname VARCHAR(40), email VARCHAR(80), pass VARBINARY(32), licenseno VARCHAR(80), mobileno VARCHAR(10)) BEGIN SET @fname = fname, @lname = lname, @email = email, @pass = pass, @licenseno = licenseno, @mobileno = mobileno; SET @sql = 'INSERT INTO user_account(email,pass,last_name,license_no,phone_no) VALUES(?,?,?,?,?)'; PREPARE stmt FROM @sql; EXECUTE stmt USING @email,@pass,@lname,@licenseno,@mobileno; END$$ DELIMITER; When i test these from php sample script insert is not working , but first stored procedure(reg_check_email()) is working. If i comment off first one(reg_check_email), second stored procedure(reg_insert_into_db) is working fine. <?php require("/wamp/mysql.inc.php"); $r = mysqli_query($dbc,"CALL reg_check_email('[email protected]')"); $rows = mysqli_num_rows($r); if($rows == 0) { $r = mysqli_query($dbc,"CALL reg_insert_into_db('a','b','[email protected]','c','d','e')"); } ?> i'm unable to figure out the mistake. Thanks in advance, ravi.

    Read the article

  • reading csv files in scipy/numpy in Python

    - by user248237
    I am having trouble reading a csv file, delimited by tabs, in python. I use the following function: def csv2array(filename, skiprows=0, delimiter='\t', raw_header=False, missing=None, with_header=True): """ Parse a file name into an array. Return the array and additional header lines. By default, parse the header lines into dictionaries, assuming the parameters are numeric, using 'parse_header'. """ f = open(filename, 'r') skipped_rows = [] for n in range(skiprows): header_line = f.readline().strip() if raw_header: skipped_rows.append(header_line) else: skipped_rows.append(parse_header(header_line)) f.close() if missing: data = genfromtxt(filename, dtype=None, names=with_header, deletechars='', skiprows=skiprows, missing=missing) else: if delimiter != '\t': data = genfromtxt(filename, dtype=None, names=with_header, delimiter=delimiter, deletechars='', skiprows=skiprows) else: data = genfromtxt(filename, dtype=None, names=with_header, deletechars='', skiprows=skiprows) if data.ndim == 0: data = array([data.item()]) return (data, skipped_rows) the problem is that genfromtxt complains about my files, e.g. with the error: Line #27100 (got 12 columns instead of 16) I am not sure where these errors come from. Any ideas? Here's an example file that causes the problem: #Gene 120-1 120-3 120-4 30-1 30-3 30-4 C-1 C-2 C-5 genesymbol genedesc ENSMUSG00000000001 7.32 9.5 7.76 7.24 11.35 8.83 6.67 11.35 7.12 Gnai3 guanine nucleotide binding protein alpha ENSMUSG00000000003 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 Pbsn probasin Is there a better way to write a generic csv2array function? thanks.

    Read the article

  • MySQL Stored Procedures not working with SELECT (basic question)

    - by TMG
    Hello, I am using a platform (perfectforms) that requires me to use stored procedures for most of my queries, and having never used stored procedures, I can't figure out what I'm doing wrong. The following statement executes without error: DELIMITER // DROP PROCEDURE IF EXISTS test_db.test_proc// CREATE PROCEDURE test_db.test_proc() SELECT 'foo'; // DELIMITER ; But when I try to call it using: CALL test_proc(); I get the following error: #1312 - PROCEDURE test_db.test_proc can't return a result set in the given context I am executing these statements from within phpmyadmin 3.2.4, PHP Version 5.2.12 and the mysql server version is 5.0.89-community. When I write a stored procedure that returns a parameter, and then select it, things work fine (e.g.): DELIMITER // DROP PROCEDURE IF EXISTS test_db.get_sum// CREATE PROCEDURE test_db.get_sum(out total int) BEGIN SELECT SUM(field1) INTO total FROM test_db.test_table; END // DELIMITER ; works fine, and when I call it: CALL get_sum(@t); SELECT @t; I get the sum no problem. Ultimately, what I need to do is have a fancy SELECT statement wrapped up in a stored procedure, so I can call it, and return multiple rows of multiple fields. For now I'm just trying to get any select working. Any help is greatly appreciated.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >