由买买提看人间百态

topics

全部话题 - 话题: inputfile
1 (共1页)
n********n
发帖数: 529
1
这是我当时写的,1个半小时左右吧。
/////////////////////////////////////////////////////
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.HashSet;
public class TestForSalesforce {
// Variable to track the dependencies
HashMap> deps = new HashMap String>>();
// Variable to track the installed commands
HashMap ins = new HashMap();

public boolean... 阅读全帖
s******a
发帖数: 517
2
你的意思:grep abc inputfile |grep -v bcd
需要两次grep,我只想用一次,原因是我要找符合条件的下一行,比如inputfile如下
0 abcd
1 unmatch ha ha
2 abcxyz
3 match ha ha
我只想显示含ha的第3行。如果一个grep可以做到过滤出第2行的话,可以用以下命令:
grep unknown_pattern -A1 inputfile |grep ha
G********7
发帖数: 234
3
来自主题: Programming版 - 问一个python问题
要把在text里的数据转到csv格式, 程序如下。第四步(# Text file to CSV)出错。
出错提示是
“Traceback (most recent call last):
File "C:\yw\LatLon\txt2csv.py", line 24, in
txt = f.readline()
ValueError: Mixing iteration and read methods would lose data”
望赐教。多谢!
***********************************************
# Import Modules
import os,sys
# Variables
path = os.getcwd()
inputFile = os.path.join(path, "raw_files", "JAN 2013
FLVERTEXFLVertexFLVertex.txt")
CSVfile = os.path.join(path, "temp", "LatLon.csv")
print input... 阅读全帖
v*****r
发帖数: 1119
4
来自主题: Linux版 - 求助文件切割问题
凑个热闹,如果楼主需要切割任意长的文件,scripting is necessary, perl or
python can do the job nicely but a little bit overkill. AWK 是做这种工作的最
好选择之一,只需要一行 code:
awk 'BEGIN {f=10;l=f+1949;}{if(NR<=l && NR>=f) print >(f"_"l".txt"); else
if(NR>l) f=l+10;l=f+1949;}' < inputfile.txt
说明:
1. 要被切割的是 inputfile.txt
2. 新产生的 outputfiles will take the format of .txt,
for example, 10_1959.txt,1969_3918.txt,3928_5877.txt and so on...
i*e
发帖数: 352
5
来自主题: Programming版 - 脚本问题求教
想了两个,不知道可行否
sed 's/s+/t/g; s/t/n/2' inputfile > outputfile
awk -F '[[:blank:]]+' '{OFS="t"; print $1,$2"n"$3,$4}' inputfile >
outputfile
e****e
发帖数: 179
6
【 以下文字转载自 Linux 讨论区 】
发信人: engine (boxing cat), 信区: Linux
标 题: help on replacing text in a file
发信站: BBS 未名空间站 (Wed Oct 31 11:42:35 2007)
I would like to replace string 1 with string 2 in file3.dat, here is what I
did:
#!/usr/bin/perl
@inputfile= ("string1");
@outputfile=("string2");
@attfile=("file3.dat");
$mytempfile=$inputfile[0];
$youtempfile=$outputfile[0];
$hisfile=$attfile[0];
perl -pi -e 's/$mytempfile/$youtempfile/' $hisfile;
The program reports an error:
Scalar found where operator ex
w******1
发帖数: 520
7
来自主题: JobHunting版 - Bitmap是怎么回事啊?
什么是BITMAP, 怎么个结构啊?
看到很多人在讨论BITMAP, 可是GOOGLE BITMAP, 出来的结果都不是算法啊, 都是图
像处理的。
用128MB的内存做一个BitMap~
然后把原来的文件遍历一次,每读一个数都在上述BitMap中标记~按位取或预算~
索引就是这个数字的大小~结束后,扫描bitMap,找到没有标记的即可~
for(unsigned int i=0;i<0xffffffff;i++){ unsigned temp=next integer from
inputfile; bitmap[temp]=1;}for(unsigned int i=0;i<0xffffffff;i++){
if(bitmap[i]==0) output(i);} 4个月前 by rex.nani
关于代码格式化:把代码的那一部分部分全选,然后点击101010按钮 -
又:4Billion的内容,128M是不够的 -
@半瓶墨水: 128MByte*8=1Gbits=2^32 按位存的话是可以的吧~ -
@rex
j*****y
发帖数: 1071
8
来自主题: JobHunting版 - 发一个刚面的startup面经
第二题我习惯用 fstream
ofstream file(inputFile);
for(int i = 0; i < n; ++i)
{
string s(array[i]);
s.append(1, '\0');
file<< s;
}
file.close();
Y**3
发帖数: 21
9
来自主题: JobHunting版 - file 输入和 stdin 输入
输入重定向啊,程序 < inputfile
r****r
发帖数: 159
10
来自主题: JobHunting版 - 求解一道题 思路也好
ReplacementGrammar
Problem:
You will receive a message that must be translated by several string
replacement rules. However, the exact replacement rules are not fixed - they
will be provided as part of the input. You are to write a program that
receives a list of string replacements rules followed by a message, and
outputs the translated message.
Details:
0) A 'newline' consists of a carriage feed 'r' followed by a line feed 'n'.
1) The input will begin with any number of 'string replacement rul... 阅读全帖
H**********5
发帖数: 2012
11
txt文档三行数据,想读到结构体中
yingduSB, 61 , 65, 43, 65, 54, 43, 65
sanjie.haojian, 91, 90, 80, 100, 89, 99, 88
sange.haoer, 98, 92, 80, 100, 89, 99, 88
while (NULL!=fgets(line,60,inputFile))
{
sscanf(line,"%20[^,],%[0-9^,],%[0-9^,],%[1-9^,],%[1-9^,],%[1-9^,
][^/n]",&stu[nIndex].name,
&stu[nIndex].quiz1,
&stu[nIndex].quiz2,
&stu[nIndex].quiz3,
&stu[nIndex].quiz4,
&stu[nIndex].midi);
//&... 阅读全帖
z*l
发帖数: 763
12
【 以下文字转载自 Linux 讨论区 】
【 原文由 zhl 所发表 】
After you compiled your programm, you may get no warning
no error, smooth compiling. But is your programm perfect?
Try: lclint inputfile.c
It will tell all your small careless in your programm, which
is not a good thing for a perfect programmer.
Such as you put 1 instead of 1.0 for float, you should put
(void) in front of a function if you don't wanno return value.
Parameter misc not used.
On the other hand if you don't want to be a perfect programmer
, t
a********e
发帖数: 15
13
tr -d '\r' < inputfile > outputfile
l*******G
发帖数: 1191
14
来自主题: Linux版 - shell 的替换命令怎么用
试试
sed -e 's/\/-//' inputfile > outputfile
s*******f
发帖数: 757
15
来自主题: Programming版 - Usage of Grep???help!!!
I have data files with format like this:
year,mon,day,data.....
All are numbers and are seperated by coma. Can someone give me some suggestion
how I can use grep to extract the data at certain month, say, March-May.
I tried :
grep "^[[:digit:]\{\4\}[, ][3-5]]" inputfile >outputfile
It doesn't work.
Thanks!!!
a**n
发帖数: 313
16
来自主题: Programming版 - Usage of Grep???help!!!
awk -F, '{if($2==4 || $2==5) print}' inputfile > outputfile
a**n
发帖数: 313
17
来自主题: Programming版 - Usage of Grep???help!!!
A perl solution:
#!/usr/bin/perl
# To run: perl test.pl inputfile
while(<>){
my @line = split(",",$_);
print $_ if($line[1]==3 || $line[1]==4 || $line[1]==5);
}
s*********x
发帖数: 1923
18
来自主题: Programming版 - C++ 读不规则长度文件问题
c++高手帮帮忙,有一个文件
A01 B01 (13,30,50) (20, 40, 60)
A02 B02 (13,30,50, 100, 200) (20, 40, 60, 105, 206)
我需要读出每行中的每一pair, 比如 (13, 20), (30, 40), (50, 60), 可问题是在第
三列和第四列中,我们不知道有几个数字,比如第一行中有3个pair,第二行中有4个
pair.
我现在的方法是定义四个string, a, b, c, d
fstream >> a >> b >> c >> d. then, c = (13,30,50), c++中怎么把这三个数字读出
来(比如像perl里的split function)?谢了。
Update: I solved the problem. Hope it can help others:
inputFile >> tmp >> tmp >> start >> end ;
....
num = strtok (start, ",");
while (num != NULL)
l********a
发帖数: 1154
19
来自主题: Programming版 - 问一个python问题

+1
python和c++看着有一样的函数,可是那个for .. in .. 默认会帮你调用那个东西的,改
成下面就好了应该
# Text file to CSV
for lines in open(inputFile, 'r'):
ID = lines[0:6]
LAT = lines[6:16]
LON = lines[16:27]
outputCSV.write (ID +"," + LAT + "," + LON + "," + "\n")
S*******e
发帖数: 525
20
来自主题: Programming版 - Spark 和 Tensorflow 线性回归问题
刚开始看一些Spark ML和Tensorflow的基本东西,看到下便两个程序的结果很糊涂:
为什么这么大的差异?
https://github.com/backstopmedia/tensorflowbook/blob/master/chapters/04_
machine_learning_basics/linear_regression.py
在以上程序加一行 print("w=", W.eval(), "b=", b.eval()), 得到结果是
w= [[ 3.5245235 ]
[ 1.50171268]] b= 1.14499
所以 y=3.5245235x1 + 1.50171268x2 +1.14499
我用同样的数据 (格式附后)
https://github.com/apache/spark/blob/master/examples/src/main/java/org/
apache/spark/examples/ml/JavaLinearRegressionWithElasticNetExample.java
结果是:
Coefficients: [0.3827... 阅读全帖
n*****d
发帖数: 956
21
Linux下有adobe?
手动ps2pdf: ps2pdf (or ps2pdf14) -sPAPERSIZE=a4 inputfile.ps outputfile.pdf
具体的paper size定义看一看文档吧.man ps2pdf
h*********2
发帖数: 192
22
set output OUTPUTFILE
plot INPUTFILE u 1:COL ps 0 lw 3 lc rgb "red" ti "M",
INPUTFILE2 u 1:COL ps 0 lw 3 lc rgb "purple" ti "L^{+}",
INPUTFILE3 u 1:COL ps 0 lw 3 lc rgb "blue" ti "P"
请问这个第三行 的符号 "L^{+}" 为啥出不来呢?
问下,谢谢~
A**u
发帖数: 2087
23
tell him ya......
awk 'NR>line#1 && NR outputfile
I suppose you want to print contents between line#1 to line#2.
r*****s
发帖数: 985
24
来自主题: Unix版 - a beginner's question
with enscript:
% enscript -a odd(or even) -o outputfile.ps inputfile.name
r****y
发帖数: 1437
25
来自主题: Computation版 - Matlab 回车键的问题
Under dos, you can also redirect the I/O
system('myscript.exe inputfile < bbb');

and your file bbb will be just two entery keys there.
p**e
发帖数: 126
26
来自主题: ME版 - ABAQUS初级问题
different concept. abaqus inputfile is a description of the model itself
ansys's is a description of the GUI operation to create the model
D*******a
发帖数: 207
27
来自主题: Statistics版 - how to remove "tab markers" from a txt file?
最简单的是用tr;置换成空格:
tr "\t" " " inputfile > outputfile
1 (共1页)