r****t 发帖数: 10904 | 1 a.split?
Type: builtin_function_or_method
Base Class:
String Form:
Namespace: Interactive
Docstring:
S.split([sep [,maxsplit]]) -> list of strings
Return a list of the words in the string S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator |
|
c*********h 发帖数: 125 | 2 try getline, its last parameter is delimiting character. |
|
d****e 发帖数: 251 | 3 dlmread will do the job of "option 1"
dist_matrix = dlmread('filename') % by default the delimiter is whitespace
% ignore first column
dist_matrix = dlmread('filename',' ',0,1) |
|
g****y 发帖数: 436 | 4 这两天在改一个用C写的处理文件IO和字符串的程序,遇到众多令人头疼的问题,靠着
google和自己的一些想法勉强解决了,但是效率不高,想请教一下这里的大侠:
1。从文件中读取一行,例如:
SR01.01 02 G\t-\t9908\t#@#@$@@#@#@@
现在想得到SR01.01 02 G, -, 9908这三个字符串。
首先想到用scanf("%s%s%s%*s",s1,s2,s3);
但是不工作,因为SR01.01 02 G中间有两个空格。
放狗发现了一个bstrlib.h,里面有一个bsplit,可以使用\t作为delimiter。但是太麻
烦了,所以自己写了一个getTokens。
后来发现c++ programming how to里面有一个写得很好的string类,但是我怕用了以后
导致原来的代码编译出错,所以没敢用。
2。检查子字符串,比如java有一个String.startsWith(),发现C也没有。也只好自己
写了一个。就是用一个循环比较两个字符串。不知道有没有更好的办法。
最后文一下C/C++混合代码的问题,比如
/* mix.c*/
printf("c s |
|
c*****t 发帖数: 1879 | 5 avoid using strtok at all costs. strchr is a better alternative.
scanf technically can scan with delimiter, but usually it is
faster to scan the whole line, then use strchr. |
|
g****y 发帖数: 436 | 6 多谢大侠指点!能不能推荐一下scanf的一些用法的website或者book?我搜了半天也找
不到怎么用自定义delimiter的内容。 |
|
d****p 发帖数: 685 | 7 Any white char, like space, CR and tab is a delimiter for ifstream. It looks
like difficult to change it though.
If you really want to customize it, you may consider use boost tokenizer. |
|
z****e 发帖数: 2024 | 8 or if you really want to get screen command line input as source, and you
want " " as delimiter.
string s1;
vector vstr;
getline(cin,s1);//command line input
size_t p1=0;
size_t p2=0;
while( (p2=s1.find_first_of(" ",p2)) != string::npos){
cout<
vstr.push_back(s1.substr(p1, p2-p1));
p2=s1.find_first_not_of(" ",p2);
p1=p2;
}
vstr.push_back(s1.substr(p1,p2-p1));//read the last string |
|
r****t 发帖数: 10904 | 9 (2nd function version:)
istream& getline ( istream& is, string& str );
Get line from stream
...
The delimiter character is delim for the first function version, and '\n' (
newline character) for the second. The extraction also stops if the end of
file is reached in is or if some other error occurs during the input
operation.
所以 getline 就从 hello 后面那个空格开始读到 \n 了。 |
|
m*********n 发帖数: 28 | 10 do u know python don't use "{" or "}" to delimit a function, but use
idention (tab or space). and the ident must be consistent, if you use tab,
use tab everywhere. otherwise, use space everywhere. and lines that are at
the same layer of logic must have the same amount of indention? after you
copy/paste code from bbs, you must make sure your indent is correct.
also, that guy's code is missing __main__. i think it's better for u to look
at the python doc on how to define a function, and what's a _... 阅读全帖 |
|
r*g 发帖数: 3159 | 11 手工做法:
在 Dos windows 里,
dir /B >filelists.txt
在Excel里打开 filelists.txt
用 txt to columns 转化成 column format. (用 . 做 delimiter)
对所有columns建filter. 排序。该咋整咋整,就全找出来了。
.5 |
|
t****a 发帖数: 1212 | 12 I don't really see the point of using functional programming languages for
real production projects, though clojure is very popular now.
好问题,但也许你尝试用FP语言做一做事情,亲身体验一下,会有不同的感觉。
my point is that in a few cases you do need to operate on functions, all
languages have such features: C has function pointers, java has anonymous
inner classes, python has lambda. it's just that they do not openly
advertise them as "functional".
FP和上述冯诺依曼机式语言有好些地方不一样。最主要之一是immutable的数据结构。
个人的体会是它使得写程序减少了变量,强迫程序员用类似数学推理的方式写... 阅读全帖 |
|
t****a 发帖数: 1212 | 13 I don't really see the point of using functional programming languages for
real production projects, though clojure is very popular now.
好问题,但也许你尝试用FP语言做一做事情,亲身体验一下,会有不同的感觉。
my point is that in a few cases you do need to operate on functions, all
languages have such features: C has function pointers, java has anonymous
inner classes, python has lambda. it's just that they do not openly
advertise them as "functional".
FP和上述冯诺依曼机式语言有好些地方不一样。最主要之一是immutable的数据结构。
个人的体会是它使得写程序减少了变量,强迫程序员用类似数学推理的方式写... 阅读全帖 |
|
p*****2 发帖数: 21240 | 14
Scala 2.10 has integrated the Future concept from Akka, still available by
means of Akka for Scala < 2.10. You are right, Task is analogous to
Future[T] from Scala.
I also don't like the async/await feature from C# or the experimental
delimitated continuations support. Async programming by means of Futures
works great without it and looking at my code, I don't see many places where
I could actually use the async/await syntactic sugar. That's because
modelling computations in terms of Future... 阅读全帖 |
|
c******o 发帖数: 1277 | 15 用了几个月scala. 说一下我的感觉
scala是一个general purpose language, 它有足够的工具解决绝大部分项目和问题。
scala不是一个all purpose language,它明显在很多领域只是可以用而已。大部分领域
有更好的语言了。
我的感觉是,scala最适用于:
1. 多并发,大规模的后端,很好的支持并发。
2. 分布式系统,高可用性,高容错,分布式实现容易。
3. 复杂逻辑后端,有很多很好的抽象方法可以选用,用的好,可以很干净。
4. 各种专业的库,是一个很好的建库的语言,当然,要求也高。
这些主要是因为:
1. FP和OO的融合使得scala有很强大的标准库支持,也很容易使人迷惑, 看看那个
play的Json library, 很强大,也很囧。
2. FP和OO的融合使得scala有很多种抽象的方法,很强大,但是也很容易被滥用,太多
pattern可以用来干同一件事。
3. 静态类型和type inference使得scala很适合大型,复杂的系统,高效的系统,也能
够写出比较简洁和干净的代码,要是不注意,容易影响可读性。
4. 调用jav... 阅读全帖 |
|
k**********g 发帖数: 989 | 16
是operation 前和後的分别。
Thrust 的答案也是很重要的。建议再多做几个测试。
In your code, the stream's state is tested first and then the string is read
. in Thrust's code, the string is read first, and then the stream's state is
tested. If the test is bad, the string is thrown away.
You should do a few more tests, e.g. a string that ends with a whitespace (
the delimiter), a string that contains a single word (no whitespace at all),
etc., to make sure the code satisfies all of your needs. |
|
c******o 发帖数: 1277 | 17 是的,都是在akka上建造的。
spark会大量应用内存缓存(分布性的),用delimited continuation skip
intermediate result. 在一个共同的base上做stream, interactive(sql like),
batch, graph, ML
可以数据和逻辑共享。
其实也有点大而全。。(希望不会太过)而且还在发展阶段。 |
|
G********7 发帖数: 234 | 18 手上有一个 pipe-delimited text file。要实现以下两点:
1.找出第三列中不带负号(-)的,补上
2.报.txt 文件转换成.csv文件
200240|33.7885877|-88.4532743
201160|34.1431677|-88.6621770
201180|32.1650841|-95.5436185
201250|32.0635069|-95.6877344
201350|33.8531891|-88.4066804
201360|34.0300324|-88.4172026
202060|34.0625840|88.6878836
应该怎么做呢?多谢! |
|
W***o 发帖数: 6519 | 19 我有一个csv文件,里面有多行多栏的数据,我想把这些数据通过3D surface plot表述
出来(x轴坐标就用第一列每行的cell 内容,比如Log1, Log2...; y轴就用第一行的cell
content (Sample1, Sample2 ...),z就用下面表格里的数据。我想到用matplotlib,
但是又不太会用,想请教一下。
Measure# Sample1 Sample2 Sample3 Sample4 Sample5
Log1 2.3 3.3 4.5 5.6 6.7
Log2 3.5 6.7 10.0 22.1 30
Log3 4.2 4.5 6.7 8.9 9.1
Log4 4.5 8.9 10.2 11.8 14.7
import csv
from matplotlib import pyplot as plt
import pylab
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
csv_file_path='/path/to/my/C... 阅读全帖 |
|
w*x 发帖数: 518 | 20 没明白,你的code不都写出来了么?
都用matplotlib了, csv就用
import numpy as np
data = np.genfromtxt('fname.csv', delimiter=',')
来读吧…… |
|
l******9 发帖数: 579 | 21 【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: error of opening a file located in a remote server from pyton
发信站: BBS 未名空间站 (Sun Jul 27 19:03:52 2014, 美东)
I need to access read a csv file located in a server from python 3.2 on win7.
The file name is
csv_file =
file_loc = '\serverName.myCompanyName.com\mypath\Files\myfile.csv'
with open(file_loc , 'r') as csv_file # error !!!
csv_reader = csv.reader(csv_file, delimiter=',')
error:
IOError: [Err... 阅读全帖 |
|
H****S 发帖数: 1359 | 22 说到底还是actor的胜利。stm, micro还有delimited continuation 这些fancy东西实
际用得少。 |
|
j****y 发帖数: 684 | 23 Scala for the Impatient book
The [AL][1-3] refer to Martin Odersky's Scala levels.
The Basics (A1)
Control Structures and Functions (A1)
Arrays (A1)
Maps and Tuples (A1)
Classes (A1)
Objects (A1)
Packages and Imports (A1)
Inheritance (A1)
Files and Regular Expressions (A1)
Traits (L1)
Operators (L1)
Higher-Order Functions (L1)
Collections (A2)
Pattern Matching and Case Classes (A2)
Annotations (A2)
XML Processing (A2)
Type Parameters (L2)
Advanced Types (L2)
Parsing and Domain-Specific Language... 阅读全帖 |
|
b***i 发帖数: 3043 | 24 我的项目的具体设计是一个嵌入式的服务器用Linux, C++11, ASIO, JSON等
客户端向服务器请求connect
连接后,服务器向客户端发送一个问题,
客户端回答
服务器回答对了
客户端开始发送JSON
服务器解析后进行动作,然后发送返回的信息
问题在最后一行:如果这个动作需要时间,我这些动作要在handle_read里面进行,还
是另起一个线程?我在进行这些动作的时候是否可以锁定信号灯?或者是比较简单的
lock?比如我要写一个变量,但是多个server可能同时访问这个变量,所以要lock再写。
目前采用boost的一个例子:
void start_read() {
// Set a deadline for the read operation.
input_deadline_.expires_from_now(readTimeout_);
// Start an asynchronous operation to read a newline-delimited message.
asio::async_read_until(socke... 阅读全帖 |
|
e*****r 发帖数: 144 | 25 我的问题是
1. we know cin will leave a new line character '\n' in the buffer.
So why the second and third cin can still get the correct input, rather than
uses '\n' as a delimiter and gets a empty string?
cin >> foo;
cin >> bar;//No problem
cin >> baz;//No problem.
2. 连续多个cin 会造成 多个 '\n' 留在 buffer里吗?
谢谢。 |
|
T*******n 发帖数: 493 | 26 Change the font size before beginning the tabular environment, e.g.:
\begin{table}
\centering
\caption{...}
\begingroup % equivalent to {, to delimit scope of font size change
\tiny
\begin{tabular}{...}
...
\end{tabular}
\endgroup % equivalent to }
\end{table}
I never heard of \squeeztable. |
|
w***d 发帖数: 17 | 27 发现一个jabref的问题。它的Entry的delimiter 都是用的 {}, 而不是"".老板说用"",
bibtex排版的时候会自动决定字母的大小写,而用{}则不行。哪位知道怎么解决这个问
题么?我找了半天jabref的设置也没查到。 |
|
T*******y 发帖数: 6523 | 28 I thought so and I tried so, but there's error message popping up
'Missing delimiter (.inserted).' at the line of \end{align}
Do you know what happened? Thanks!
\begin{align}
\begin{split}
\left \{
\begin{array}{cc}
a & b\\
c & d\\
\vdots &
\end{array}
\right
\end{split}
\end{align} |
|
T*******n 发帖数: 493 | 29
{\raggedright Text.\par}
or
\begingroup\raggedright Text.\par\endgroup
Note that the flushleft environment is basically
\raggedright surrounded by group delimiters, as I
showed above.
If you need a blank line between paragraphs, try
\begin{flushleft}
\setlength{\parskip}{\bigskipamount}
% or try \medskipamount, \smallskipamount or actual dimension
Paragraph 1.
Paragraph 2.
\end{flushleft} |
|
T*******n 发帖数: 493 | 30 Try \caption[{Conc [a]}]{The concentration is [a]}
LaTeX (actually TeX) only pairs { with }. It doesn't know how to
pair [ with ] because it regards [ ] as punctuations, not grouping
delimiters. If you want to understand the details, you need to
know what catcodes are in TeX and how macros argument lists
are parsed. |
|
T*******n 发帖数: 493 | 31 Pick a character other than / as the delimiter.
\verb|${HOME}/code|
\verb=${HOME}/code=
\verb+${HOME}/code+ |
|
A**********e 发帖数: 3102 | 32 amsmath 的 align/split 等和 \left \right 冲突,特头大。
比如说,我想打:
\left ( blah = \dfrac{\sum_i^N{blah}}{\sum_i^N{blah}} \right)
但是想在 = 处与下一行对齐。这时候 \left 和 \right 就报错了。根据 manual,
改成:
\left ( blah \right. &=
\left. \dfrac{\sum_i^N{blah}}{\sum_i^N{blah}} \right)
这时,左边的括号和`blah' 一样高,右边的和分式一样高 -_-b
如果不想手动设置括号这类 delimiter 的尺寸,想让 latex 自动处理(这个应当
是 latex 的原则吧),该咋办?amsmath 有没有提供类似的命令? |
|
A**********e 发帖数: 3102 | 33 thanks a lot, but it's different.
I just hate to manually set the size of delimiters, and want latex to do
that.
\left and \right should be the latex way, but they conflict with & in
amsmath |
|
T*******n 发帖数: 493 | 34 There is no easy way to get \left and \right to do what you want.
If there were a way, they would have implemented it already.
Even when you dont have & or \\, \left and \right don't always determine
the correct size for the fences/delimiters. See the amsmath manual for
examples.
In most cases, however, if you follow the standard mathematical
typographical rules, you only need the \bigg? macros that I have
defined. The "proper" way of setting complicated mathematical
expressions is explained i |
|
T*******n 发帖数: 493 | 35 \left and \right are used to size delimiters in equations.
The two commands corresponding to \centering are \raggedleft and \
raggedright,
but these are not what you need to solve your problem.
See my response to your other question. |
|
i**********r 发帖数: 36 | 36 as title,
a blank line as paragraph delimiter. |
|
b*****i 发帖数: 58 | 37 I tried some times to solve your problem. At the first time, I got segmental
fault, but at last I am lucky to find a way to parse the tokens.Below is an
example:
#include
#include
#include
void main()
{
char *str;
char *line="15:wildwood.eecs.umich.edu:018032:24.79";
char *delimiter=":";
char *tokenp;
int numtokens,i;
if ((str=calloc(strlen(line) + 1, sizeof(char))) == NULL)
exit(1);
else {
strcpy(str, line); |
|
a*a 发帖数: 23 | 38 I got stuck for the following problem. My shell script is as follows:
for i in `sort -u file1.txt` #the small dot here is backquote
do
echo $i
done
the file1.txt consists of two sentences :
I am a boy
you are a girl
after I run the script, the output is
$ ./li.sh
I
am
a
boy
you
are
a
girl
However, I need the output like
I am a boy
you are a girl
That is , I need variable i to be assigned the value of the whole line not a
single word delimited by the space. How should I change my scri |
|
N*********r 发帖数: 40 | 39 RTFM!
" Wget also supports the `type' feature for FTP URLs. By default, FTP
documents are retrieved in the binary mode (type `i'), which means that
they are downloaded unchanged. Another useful mode is the `a'
("ASCII") mode, which converts the line delimiters between the
different operating systems, and is thus useful for text files. Here
is an example:
ftp://host/directory/file;type=a
" |
|
T********r 发帖数: 6210 | 40
1,$: from the first line of the file to the last line
s: find some matching pattern, and replace with another pattern
/: begin the matching pattern
.: match any character
*: match any number of characters, i.e., 0 - any characters
/: end of the matching pattern, begin the replacing pattern
.\/load_image.pl Image\/: replacing pattern is ./load_image.pl Image/
note the difference between a single '/' and '\/'. for '/', it is
the delimit character between patterns. for '\/', it represents th |
|
c*r 发帖数: 278 | 41 find /home/temp -name "*name*" -print
"<..>" as the delimiter of whaterver you typed. |
|
|
r****t 发帖数: 10904 | 43 data = textread('data.csv', '', 'delimiter', ',', ...
'emptyvalue', NaN); |
|
d******u 发帖数: 178 | 44 那个应该tab-delimited txt file。用excel打开,可以看到数据结构。具体用什么软
件分析,很多软件都可以。AGILENT自己应该有推荐的分析软件,查一下就知道了。 |
|
a********h 发帖数: 245 | 45 我觉得你这个像是tag count file (参考 GBS pipeline)。
自己用 linux shell commands will do that (假设你的文件是space delimit):
cat input.txt | nl | gawk -F' ' '{print ">"$1"_"$3"\n"$2}'
>1_2
ACAAACGACTCTCGGCAACGGTTGT
>2_1
ATATGAAGACAAGTAGTGCAGCTCGGAGACGGG
>3_1
ATAATAGAGGTTTTGCAAAACAAT
sequence ID will be unique if you only have one file and also include read
number information. For multiple files, just do: cat file1 file2 file2 | nl
| gawk -F' ' '{print ">"$1"_"$3"\n"$2}' |
|
a********h 发帖数: 245 | 46 补充一个:如果是tab delimit:
cat input.txt | nl | sed 's/ //g' | gawk -F'\t' '{print ">"$1"_"$3"\n"$2}' |
|
x*****d 发帖数: 704 | 47
这个文件其实就是一个tab-delimit file,可以用excel打开。 |
|
i****f 发帖数: 432 | 48 这个问题我正好之前刚遇到过,问了我们的librarian,引用的时候正常引用,然后再手
动改,具体方法看下面:
Unformatting Citations (Microsoft Word)
Unformatting reverts formatted citations to temporary citations, removes the
bibliography, and turns off instant formatting.
If your citations are formatted in a numbered style, you can unformat your
paper to easily identify citations as you work. You can Format Bibliography
again later.
Note: Unlike formatted citations, unformatted citations require that you
have the corresponding EndNote library op... 阅读全帖 |
|
G***G 发帖数: 16778 | 49 a tab delimited text file has 7 columns
the 7th column is pvalue.
which bash command can let us choose all the rows with pvalue <0.01?
suppose the result file is A.
I have another two questions about bash.
How to remove first line from a file B using bash, and then combine with
file A
into a new file C?
Sorry, I am a windows guy, not familiar with mac or linux. |
|
O******e 发帖数: 734 | 50 Do you have any idea what is in the file or what the format might
be? If it had been written by a Fortran program using sequential
access binary output, there should be record delimiters in the file.
Each record normally as the following format:
[4-byte int N][data in the record][4-byte int N repeated]
If you are sure that the data part contains only double or single
precision real, complex, or integer data, then the length of the
data part is usually either N bytes (more common) or 4*N bytes
( |
|