output

PHP output to file for download without creating file on the server

故事扮演 提交于 2019-12-01 11:52:31
I would like to output my data to a file for the user to download without actually creating the file physically on the server. The data of the file is simply array that I'm converting into a CSV format for the user to download. Here's my code: $fh = fopen('file.csv','w'); fputcsv($fh,$arr); // $arr is my array that contains the data to be parsed into CSV fclose($out); The above code creates the file successfully... but I don't want to have to create a file. I want to simply stream the output. Any help would be greatly appreciated! You can use header("Content-type: text/csv"); header("Cache

Can I keep old keys linked to new keys when making a copy in SQL?

梦想的初衷 提交于 2019-12-01 11:10:24
问题 I am trying to copy a record in a table and change a few values with a stored procedure in SQL Server 2005. This is simple, but I also need to copy relationships in other tables with the new primary keys. As this proc is being used to batch copy records, I've found it difficult to store some relationship between old keys and new keys. Right now, I am grabbing new keys from the batch insert using OUTPUT INTO. ex: INSERT INTO table (column1, column2,...) OUTPUT INSERTED.PrimaryKey INTO

Error in using `struct.pack` for writing data to file

给你一囗甜甜゛ 提交于 2019-12-01 08:41:15
I have a numpy.ndarray sample of numbers, each between 1 and 2**20 . I'd like to write it into a binary file, such that each element is represented by four bytes. However, the resulting file size is different from 4 times the size of the sample. This is the code I'm using: outputFile = open('testDS', 'w') print len(sample) if (outputFile is not None): for s in sample: assert(s < 2**20) r = struct.pack("i", s) assert(len(r) == 4) outputFile.write(r) outputFile.close() The output I'm getting (the size of the sample) is: 1000 However, the resulting file size is 4026 bytes. Any ideas why the file

Error in using `struct.pack` for writing data to file

有些话、适合烂在心里 提交于 2019-12-01 05:40:35
问题 I have a numpy.ndarray sample of numbers, each between 1 and 2**20 . I'd like to write it into a binary file, such that each element is represented by four bytes. However, the resulting file size is different from 4 times the size of the sample. This is the code I'm using: outputFile = open('testDS', 'w') print len(sample) if (outputFile is not None): for s in sample: assert(s < 2**20) r = struct.pack("i", s) assert(len(r) == 4) outputFile.write(r) outputFile.close() The output I'm getting

Gathering all the unique values from one column and outputting them in another column..?

限于喜欢 提交于 2019-12-01 05:30:57
I have this form of a spreadsheet: A B C D abc abc abc 1 def ghi jkl 1 mno pqr stu 3 vwx yza bcd 4 mno pqr stu 5 mno pqr stu 5 vwx yza bcd 5 mno pqr stu 1 Where the first 3 columns are just data of type string. The column D has integers which has numbers repeating. My question is how to output a fifth column like so: A B C D E abc abc abc 1 1 def ghi jkl 1 3 mno pqr stu 3 4 vwx yza bcd 4 5 mno pqr stu 5 mno pqr stu 5 vwx yza bcd 5 mno pqr stu 1 It only outputs the unique numbers from column D. I imagined running an if/else statement in a for or while loop that checks each cell in "D" and

Capture the output of an external program in JAVA

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 03:47:14
I'm trying to capture output of an external program using java but I can't. I have the code to show it, but not to put it into a variable. I will use, for example, sqlplus to execute my oracle code "into exec.sql" system/orcl@orcl : user/password/DB name public static String test_script () { String RESULT=""; String fileName = "@src\\exec.sql"; String sqlPath = "."; String arg1="system/orcl@orcl"; String sqlCmd = "sqlplus"; String arg2 = fileName; try { String line; ProcessBuilder pb = new ProcessBuilder(sqlCmd, arg1, arg2); Map<String, String> env = pb.environment(); env.put("VAR1", arg1);

Eclipse Console not showing output

坚强是说给别人听的谎言 提交于 2019-12-01 03:37:18
I have written a simple class having an SOP statement for "Hello World". But the Eclipse console is not showing output. I then wrote the same program in a previously created project and it worked fine. I am opening the Console as given below: Window->Show View->Console. But it is not working. I am using j2ee project in the same workspace. Any idea? Please help. I am stuck because of this problem. Go to "Window > Reset Perspective", that will reset the window settings to default. Next, you might need to stop any running Java processes. I suggest you then click "Remove all Terminated Launches"

Python - Compare 2 files and output differences

丶灬走出姿态 提交于 2019-12-01 02:38:39
I'm aiming to write a script that will compare each line within a file, and based upon this comparison, create a new file containing the lines of text which aren't in the second file. For example; **File 1:** Bob:20 Dan:50 Brad:34 Emma:32 Anne:43 **File 2:** Dan:50 Emma:32 Anne:43 The new output (File 3): Bob:20 Brad:34 I have some idea of how this needs to be done, but not exactly: def compare(File1,File2): with open(File1, "a") as f1: lines = f1.readlines() string = line.split(':') with open(File2, "a") as f2: lines = f2.readlines() string2 = line.split(':') if string[0] == string[1]: with

Capture the output of an external program in JAVA

纵然是瞬间 提交于 2019-12-01 00:45:02
问题 I'm trying to capture output of an external program using java but I can't. I have the code to show it, but not to put it into a variable. I will use, for example, sqlplus to execute my oracle code "into exec.sql" system/orcl@orcl : user/password/DB name public static String test_script () { String RESULT=""; String fileName = "@src\\exec.sql"; String sqlPath = "."; String arg1="system/orcl@orcl"; String sqlCmd = "sqlplus"; String arg2 = fileName; try { String line; ProcessBuilder pb = new

OpenCV documentation says that “uchar” is “unsigned integer” datatype. How?

南楼画角 提交于 2019-11-30 23:10:43
I got confused with the openCV documentation mentioned here . As per the documentation, if i create an image with "uchar" , the pixels of that image can store unsigned integer values but if i create an image using the following code: Mat image; image = imread("someImage.jpg" , 0); // Read an image in "UCHAR" form or by doing image.create(10, 10, CV_8UC1); for(int i=0; i<image.rows; i++) { for(int j=o; j<image.cols; j++) { image.at<uchar>(i,j) = (uchar)255; } } and then if i try to print the values using cout<<" "<<image.at<uchar>(i,j); then i get some wierd results at terminal but if i use the