Search Results

Search found 11972 results on 479 pages for 'writing'.

Page 33/479 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Writing to CSV issue in Spyder

    - by 0003
    I am doing the Kaggle Titanic beginner contest. I generally work in Spyder IDE, but I came across a weird issue. The expected output is supposed to be 418 rows. When I run the script from terminal the output I get is 418 rows (as expected). When I run it in Spyder IDE the output is 408 rows not 418. When I re-run it in the current python process, it outputs the expected 418 rows. I posted a redacted portion of the code that has all of the relevant bits. Any ideas? import csv import numpy as np csvFile = open("/train.csv","ra") csvFile = csv.reader(csvFile) header = csvFile.next() testFile = open("/test.csv","ra") testFile = csv.reader(testFile) testHeader = testFile.next() writeFile = open("/gendermodelDebug.csv", "wb") writeFile = csv.writer(writeFile) count = 0 for row in testFile: if row[3] == 'male': do something to row writeFile.writerow(row) count += 1 elif row[3] == 'female': do something to row writeFile.writerow(row) count += 1 else: raise ValueError("Did not find a male or female in %s" % row)

    Read the article

  • Help needed in writing regular expression -- TCL

    - by user330727
    Hello Everyone, Just seeking a favour to write a regular expression to match the following set of strings. I want to write an expression which matches all the following strings TCL i) ( XYZ XZZ XVZ XWZ ) Clue : Starting string is X and Z ending string is same for all the pairs. Only the middle string is differs Y Z V W. My trial: [regexp {^X([Y|Z|V|W]*)Z$}] I want to write an another regexp which catches/matches only the following string wherever comes ii) (XYZ) My trial: [regexp {^X([Y]*)Z$}]

    Read the article

  • What I need to know for writing a Camera Component

    - by Delphawi
    I want to write a component that uses 2 webcams (1 integrated in my laptop , the other is a USB webcam) What do I need to know (or have) to build a component to deal with the cameras (capture , record , movement recognition , and other image and video processing) ? and how ? (with C++ or Delphi) I just need to know the concepts and main techniques , any good resources or source codes would be great :) Thank you .

    Read the article

  • Writing a unique identifier to script?

    - by dannycab
    I'd like to write a subscript that adds a unique identifier (machine time) to a script everytime that it runs. However, each time I edit the script (in IDLE) the indetifiers are over-written. Is there a elegant way of doing this. The script that I wrote appears below. import os, time f = open('sys_time_append.py','r') lines = f.readlines() f.close() fout = open('sys_time_append.py','w') for thisline in lines: fout.write(thisline) fout.write('\n#'+str(time.time())+' s r\n') fout.close() Thanks for any help.

    Read the article

  • writing a shell script if statement to check for directory

    - by user1553248
    I need to write a script that will recreate my opt folder if it gets deleted when I remove a package from it. Here's a link to my previous post: dpkg remove to stop processes Now, the issue I'm running into could be better described here: http://lists.debian.org/debian-devel/2006/03/msg00242.html I was thinking of just adding a postrem script which checks if an opt directory exists, and if not, creates one. My experience with shell scripts is pretty limited though..

    Read the article

  • Writing Great Software

    - by 01010011
    Hi, I'm currently reading Head First's Object Oriented Analysis and Design. The book states that to write great software (i.e. software that is well-designed, well-coded, easy to maintain, reuse, and extend) you need to do three things: Firstly, make sure the software does everything the customer wants it to do Once step 1 is completed, apply Object Oriented principles and techniques to eliminate any duplicate code that might have slipped in Once steps 1 and 2 are complete, then apply design patterns to make sure the software is maintainable and reusable for years to come. My question is, do you follow these steps when developing great software? If not, what steps do you usually follow inorder to ensure it's well designed, well-coded, easy to maintain, reuse and extend?

    Read the article

  • writing structs and classes to disk

    - by Phenom
    The following function writes a struct to a file. int btwrite(short rrn, BTPAGE *page_ptr) { long addr; addr = (long) rrn * (long) PAGESIZE + HEADERSIZE; lseek(btfd, addr, 0); return (write(btfd, page_ptr, PAGESIZE)); } The following is the struct. typedef struct { short keycount; /* number of keys in page */ int key[MAXKEYS]; /* the actual keys */ int value[MAXKEYS]; /* the actual values */ short child[MAXKEYS+1]; /* ptrs to rrns of descendants */ } BTPAGE; What would happen if I changed the struct to a class, would it still work the same? If I added class functions, would the size it takes up on disk increase?

    Read the article

  • Perl, FastCGI and writing uploaded files

    - by ibogdanov
    My upload function looks like: sub Upload_File{ my ($file, $mime, $description) = @_; my $file_name = param('filename'); my $data; $file = UnTaint($file); if ($mime =~ /text/) { sysopen(VAULT, "$path/$file", O_RDWR | O_EXCL | O_CREAT | O_TEXT) or die "couldn't create $file for R/W: $!\n"; } else { sysopen(VAULT, "$path/$file", O_RDWR | O_EXCL | O_CREAT | O_BINARY) or die "couldn't create $file for R/W: $!\n"; } my $upfh = \*VAULT; flock $upfh, 2; seek $upfh, 0, 0; select((select($upfh), $| = 1)[0]); while( sysread($file_name, $data, 8192) ) { syswrite($upfh, $data, 8192) or die "couldn't write $upfh: $!\n"; } close $upfh; } When I am using read and print with FastCGI upload script, files uploaded with corruptions (including simple text files), this is because perl uses buffered I/O. But when I use syswrite and sysread i.e. non-buffered I/O, as a result I get good text files, but binary files are corrupted anyway.

    Read the article

  • writing into a file in c.

    - by mekasperasky
    i have an char array b[20] which i want to write into a file . After every iteration the value of b[20] changes , so i would like to write the string in each line of the file in each iteration . So how can i change a new line in a file and also put in a array of character?

    Read the article

  • Writing at the end of file

    - by user342534
    Hi, I'm working on a system that requires high file I/O performance (with C#). Basically, I'm filling up large files (~100MB) from the start of the file until the end of the file. Every ~5 seconds I'm adding ~5MB to the file (sequentially from the start of the file), on every bulk I'm flushing the stream. Every few minutes I need to update a structure which I write at the end of the file (some kind of metadata). When flushing each one of the bulks I have no performance issue. However, when updating the metadata at the end of the file I get really low performance. My guess is that when creating the file (which also should be done extra fast), the file doesn't really allocates the entire 100MB on the disk and when I flush the metadata it must allocates all space until the end of file. Guys/Girls, any Idea how I can overcome this problem? Thanks a lot!

    Read the article

  • Writing a script with the cmd prompt.

    - by Josh
    I'm trying to make a script that will place a list (in a .csv file) of processes that are running that take up more than 10 mb of RAM and shows the time + date the script was run. My teacher did this during his lecture but I can't remember how he did it. Just trying to figure out how to be better at IT. So my question is, can anyone help me with this? I don't even know where to start.

    Read the article

  • writing 'bits' to c++ file streams

    - by Sorush Rabiee
    How can i write 'one bit' into a file stream or file structure each time? is it possible to write to a queue and then flush it ? is it possible with c# or java? this was needed when i try to implement an instance of Huffman codding. i can't write bits into files. so write them to a bitset and then (when compression was completed) write 8-bit piece of it each time (exclude last one).

    Read the article

  • Writing a file by a webservice

    - by mouthpiec
    Hi, I have a wevservice, and I would like to write logs into a textfile. My problem is that i do not know what path to give when creating the streamwriter: TextWriter tw = new StreamWriter("????"); Can you please help what path I should enter?

    Read the article

  • Java: Writing a DOM to an XML file (formatting issues)

    - by Vhaerun
    I'm using org.w3c XML API to open an existing XML file. I'm removing some nodes , and I'm adding others instead . The problem is that the new nodes that are added are written one after another , with no newline and no indentation what so ever. While it's true that the XML file is valid , it is very hard for a human to examnine it. Is there anyway to add indentation , or at least a newline after each node ?

    Read the article

  • Writing a script for reading many .csv files with similar filenames

    - by wahalulu
    I have several .csv files with similar filenames except a numeric month (i.e. 03_data.csv, 04_data.csv, 05_data.csv, etc.) that I'd like to read into R. I have two questions: Is there a function in R similar to MATLAB's varname and assignin that will let me create/declare a variable name within a function or loop that will allow me to read the respective .csv file - i.e. 03_data.csv into 03_data data.frame, etc.? I want to write a quick loop to do this because the filenames are similar. As an alternative, is it better to create one dataframe with the first file and then append the rest using a for loop? How would I do that?

    Read the article

  • c++ unicode writing is not working

    - by Jugal Kishore
    I am trying to write some Russian unicode text in file by wfstream. Following piece of code has been used for it. wfstream myfile; locale AvailLocale("Russian"); myfile.imbue(AvailLocale); myfile.open(L"d:\\example.txt",ios::out); if (myfile.is_open()) { myfile << L"?????? ????" <<endl; } myfile.flush(); myfile.close(); Something unrecognizable is written to the file by executing this code, I am using VS 2008.

    Read the article

  • Writing Logs to an XML File with .NET

    - by JL
    I am storing logs in an xml file... In a traditional straight text format approach, you would typically just have a openFile... then writeLine method... How is it possible to add a new entry into the xml document structure, like you would just with the text file approach?

    Read the article

  • Writing a collection to Excel

    - by jame
    I'm working in VS2005 and I need the C# syntax write to write collection values in an Excel sheet. I initialize the collection like this: Reports oReports =new Reports();//oReports is a collection Assuming that this collection has values, how would I write them to Excel?

    Read the article

  • Writing a C++ wrapper for a C library

    - by stripes
    I have a legacy C library, written in an OO type form. Typical functions are like: LIB *lib_new(); void lib_free(LIB *lib); int lib_add_option(LIB *lib, int flags); void lib_change_name(LIB *lib, char *name); I'd like to use this library in my C++ program, so I'm thinking a C++ wrapper is required. The above would all seem to map to something like: class LIB { public: LIB(); ~LIB(); int add_option(int flags); void change_name(char *name); ... }; I've never written a C++ wrapper round C before, and can't find much advice about it. Is this a good/typical/sensible approach to creating a C++/C wrapper?

    Read the article

  • Shell Scripting: Generating output file name in script and then writing to it

    - by NewShellScripter
    Hello, I have a shell script where a user passes different sizes as command line arguments. For each of those sizes, I want to perform some task, then save the output of that task into a .txt file with the size in the name. How can I take the command line passed and make that part of a stringname for the output file? I save the output file in a directory specified by another command line argument. Perhaps an example will clear it up. In the foor lop, the i value represents the command line argument I need to use, but $$i doesnt work. ./runMe arg1 arg2 outputDir [size1 size2 size3...] for ((i=4; i<$#; i++ )) do ping -s $$i google.com >> $outputDir/$$iresults.txt done I need to know how to build the $outputDir/$$iresults.txt string. Also, the ping -s $$i doesnt work. Its like I need two levels of replacement. I need to replace the $[$i] inner $i with the value in the loop, like 4 for ex, making it $4. Then replace $4 with the 4th command line argument! Any help would be greatly appreciated. Thanks!

    Read the article

  • Is there any alternative way of writing this switch statement(C#3.0)

    - by Newbie
    Can it be done in a better way public static EnumFactorType GetFactorEnum(string str) { Standardization e = new Standardization(); switch (str.ToLower()) { case "beta": e.FactorType = EnumFactorType.BETA; break; case "bkp": e.FactorType = EnumFactorType.BOOK_TO_PRICE; break; case "yld": e.FactorType = EnumFactorType.DIVIDEND_YIELD; break; case "growth": e.FactorType = EnumFactorType.GROWTH; break; case "mean": e.FactorType = EnumFactorType.MARKET_CAP; break; case "momentum": e.FactorType = EnumFactorType.MOMENTUM; break; case "size": e.FactorType = EnumFactorType.SIZE; break; case "stat_fact1": e.FactorType = EnumFactorType.STAT_FACT_1; break; case "stat_fact2": e.FactorType = EnumFactorType.STAT_FACT_2; break; case "value": e.FactorType = EnumFactorType.VALUE; break; } return e.FactorType; } If I create a Static class(say Constatant) and declare variable like public static string BETA= "beta"; and then if I try to put that in the Case expression like Case Constants.BETA : e.FactorType = EnumFactorType.BETA; break; then the compiler will report error.(quite expected) So is there any other way?(I canot change the switch statement) Using C#3.0 Thanks

    Read the article

  • More efficient way of writing this javascript

    - by nblackburn
    I am creating a contact form for my website and and using javascript to the first layer of validation before submitting it which is then checked again via php but i am relatively new to javascript, here is my script... $("#send").click(function() { var fullname = $("input#fullname").val(); var email = $("input#email").val(); var subject = $("input#subject").val(); var message = $("textarea#message").val(); if (fullname == ""){ $("input#fullname").css("background","#d02624"); $("input#fullname").css("color","#121212"); }else{ $("input#fullname").css("background","#121212"); $("input#fullname").css("color","#5c5c5c"); } if (email == ""){ $("input#email").css("background","#d02624"); $("input#email").css("color","#121212"); }else{ $("input#email").css("background","#121212"); $("input#email").css("color","#5c5c5c"); } if (subject == ""){ $("input#subject").css("background","#d02624"); $("input#subject").css("color","#121212"); }else{ $("input#subject").css("background","#121212"); $("input#subject").css("color","#5c5c5c"); } if (message == ""){ $("textarea#message").css("background","#d02624"); $("textarea#message").css("color","#121212"); }else{ $("textarea#message").css("background","#121212"); $("textarea#message").css("color","#5c5c5c"); } if (name && email && subject && message != ""){ alert("YAY"); } }); How can i write this more efficiently and make the alert show if all the fields are filled out, thanks.

    Read the article

  • Writing module to get video/audio from HDMI

    - by Martin
    I would like to write a small module that can check if anything is connected to my computer's HDMI input, and if so write a frame of video to bitmap once in a while. Can anyone point me to resources regarding grabbing audio/video from HDMI on windows?

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >