Search Results

Search found 631 results on 26 pages for 'newline'.

Page 7/26 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Match a comma followed by a newline with a regular expression

    - by MarathonStudios
    I have a comma delimited list I want to import into a database, and in some cases the last item is blank: item1, item2, item3 item1, item2, item1, item2, I'd like to replace all of these empty columns with a placeholder value using a regexp item1, item2, item3 item1, item2, PLACEHOLDER item1, item2, PLACEHOLDER I tried preg_replace("/,\n/", ",PLACEHOLDER\n",$csv);, but this isn't working. Anyone know what regexp would work for this?

    Read the article

  • How to read input until the user enters ^X

    - by Koning Baard
    I am creating an interpreter for my esolang, and I need the user to enter some text which then will be interpreted as an INTERCAL program. I want the user to enter text, which may contain any character including newlines, until the user presses ^X (Ctrl-X), like this: Enter your code followed by ^X: Bla Blablabla Bla^X Thank you for entering your code (line 2, 3 and 4 were entered by the user) can anyone explain me how I can read input including newlines till the user enters ^X? Thanks

    Read the article

  • PHP New Line will not work

    - by user364333
    Hi I am trying to create some code that first reads the existing contents of the file in and then adds the new line of code on a new line but the code i am using just adds it on the new text on to the already existing line instead of the new line... Here is the code i am using: <?php $id = $_GET['id']; $userfile = "user1.txt"; $fo = fopen($userfile, 'r') or die("can't open favourites file"); $currentdata = fread($fo, filesize($userfile)); fclose($fo); $fw = fopen($userfile, 'w') or die("can't open favourites file"); $currentprocessed = "$currentdata\n"; fwrite($fw, $currentprocessed); fwrite($fw, $id); fclose($fw); ?> I have tried a whole range of different ideas but nothing has worked, any help would be appreciated.

    Read the article

  • I suspect I have multiple version of Python 2.6 installed on Mac OS X 10.6.3; how do I set which one

    - by cojadate
    When I enter in python in Terminal it loads up Python 2.6.2. However there are folders by the name of Python 2.6 in different places on my drive. I'm not sure if that's because Python 2.6 has been installed in different places or because Python just likes to have lots of folers in different places. If there are multiple installations, I could really do with being able to set which one should be used.

    Read the article

  • C++ new line not translating

    - by m3n
    First off, I'm a complete beginner at C++. I'm coding something using an API, and would like to pass text containing new lines to it, and have it print out the new lines at the other end. If I hardcode whatever I want it to print out, like so printInApp("Hello\nWorld"); it does come out as separate lines in the other end, but if I retrieve the text from the app using a method that returns a const char then pass it straight to printInApp (which takes const char as argument), it comes out as a single line. Why's this and how would I go about to fix it?

    Read the article

  • Perl ENV variable contains newline and tab

    - by Michael
    Say I have an environment variable myvar myvar=\tapple\n when the following command will print out this variable perl -e 'print "$ENV{myvar}"' I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it? In the real world $ENV residing in substitution, but I hope the answer will cover that.

    Read the article

  • (C++) While reading a file (ifstream), is there any way to direct it to make a new line?

    - by Enzo
    While reading a file (ifstream), is there any way to direct it to make a new line? For instance, I would like for THIS to happen: myfilearray[1]array[2]endl; Obviously, the "endl" just isn't allowed. Is there another way to do this? Edit---thanks for the quick responses guys! From a text file, I'm trying to store two strings from that file into arrays and then do the same with the next line (or until I desire, using a for loop) Using strings is important to me as it will make my future program a lot more flexible.

    Read the article

  • How to identify/handle text file newlines in Java?

    - by rafrafUk
    Hi Everyone! I get files in different formats coming from different systems that I need to import into our database. Part of the import process it to check the line length to make sure the format is correct. We seem to be having issues with files coming from UNIX systems where one character is added. I suspect this is due to the return carriage being encoded differently on UNIX and windows platform. Is there a way to detect on which file system a file was created, other than checking the last character on the line? Or maybe a way of reading the files as text and not binary which I suspect is the issue? Thanks Guys !

    Read the article

  • How do I escape a new line character in a .ini file so that Zend_Config_Ini reads it literally?

    - by Nick
    I am trying to store a multiple line e-mail in an ini file using PHP/Zend Framework. My string has new lines characters in it, and when I use Zend_Config_Ini to parse the ini file, the new line characters come back escaped, so they are printed out on screen, instead of a line feed. Example: // ini file message = Hi {0},\n\nThis is a test message.\nGoodbye! is parsed by Zend_Config_Ini as: Hi {0},\\n\\nThis is a test message.\\nGoodbye! which then is printed out in the email as: Hi John,\n\nThis is a test message.\nGoodbye! Instead I want the e-mail to look like this: Hi John, This is a test message. Goodbye! Does anybody know how to achieve this? Thanks!

    Read the article

  • How to get line count from variable (from MYSQL query)?

    - by Mint
    My problematic code: testMYSQL=`mysql -u $mysqlUser -p$mysqlPass -h $mysqlHost --skip-column-names --batch -D $mysqlDB -e "SELECT $select FROM $mysqlTable WHERE nameTXT='test';"` $testMYSQL now contains: test test test Then I do: TEST=$(echo $testMYSQL | wc -l) echo "$TEST" I would of thought that would work, but it doesn't, it returns 1 But if I put this into $testMYSQL: "test\ntest\ntest" it will say 3… Whats going on here? does MYSQL not use new lines? PS, I know I can use a for loop to loop though the lines then count up the lines that way, but I was hoping for a simpler solution like wc

    Read the article

  • Using PHP to Seperate Results of a txt file

    - by outbreak
    I am trying to display the last 10 lines of a File and from there take those results and break them down to 10 individual lines.. Currently the code I have found from examples is: $filearray = file("test.txt"); $lastfifteenlines = array_slice($filearray,-10); echo implode($lastfifteenlines, "\n") It display's the 10 items I need however it does not break them down onto individual lines the current results are: 1.0.0.11 1.0.0.12 1.0.0.13 1.0.0.14 1.0.0.15 I need that to instead display as: 1.0.0.11 1.0.0.12 1.0.0.13 1.0.0.14 1.0.0.15 Thanks in Advance for the Asistance!

    Read the article

  • How do I find everything between two characters after a word using grep, without outputting the entire line?

    - by Nick Sweeting
    I am downlading the info.0.json file from xkcd and trying to parse just the alt text. I don't care if there are quotes around it or not. The problem it that the info.0.json file is all one line, and the alt text is in quotes after the word "alt=". Trying cat info.0.json | grep alt just returns the whole file (because it's all one line). What is the grep or sed code that will get me the alt text?

    Read the article

  • Extra line breaks inserted in MrEd text%

    - by Jesse Millikan
    In a DrScheme project, I'm using a MrEd editor-canvas% with text% and inserting a string from a literal in a Scheme file. This results in an extra blank line in the editor for each line of text I'm trying to insert. Is this a Windows vs. Unix linebreak problem? I can't find anything about text% treats line breaks in the documentation. ; Inside a class definition: (define/public (edit-pattern p j b d h) (send input-beat set-value (number->string b)) (send input-dwell set-value (number->string d)) (send hold-beats set-value (number->string h)) (send juggler-t erase) ; Why do these add extra newlines (send juggler-t insert j) (send pattern-t erase) (send pattern-t insert p)) (define juggler-ec (new editor-canvas% [parent this] [line-count 12])) (define juggler-t (new text%)) (send juggler-ec set-editor juggler-t) (define pattern-ec (new editor-canvas% [parent this] [line-count 20])) (define pattern-t (new text%)) (send pattern-ec set-editor pattern-t) ; Lots of other stuff...

    Read the article

  • Generating 8000 text files from xml files

    - by Ray
    Hi all, i need to generate the same number of text files as the xml files i have. Within the text files, i need the title and maybe some other tags of it. I can generate text files with the elements i wanted but not all xml files can be generated. Only some of them are generated. Something might be wrong with my parser so help out please thanks. This is my code. Please have a look and give me suggestions. Thanks in advance. import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.*; import java.io.*; public class AccessingXmlFile1 { public static void main(String argv[]) { try { //File file = new File("C:\\MyFile.xml"); // create a file that is really a directory File aDirectory = new File("C:/Documents and Settings/I2R/Desktop/test"); // get a listing of all files in the directory String[] filesInDir = aDirectory.list(); System.out.println(""+filesInDir.length); // sort the list of files (optional) // Arrays.sort(filesInDir); //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // have everything i need, just print it now for ( int a=0; a<filesInDir.length; a++ ) { String xmlFile = filesInDir[a]; String newLine = System.getProperty("line.separator"); File file = new File(xmlFile); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(file); document.getDocumentElement().normalize(); //System.out.println("Root element " + document.getDocumentElement().getNodeName()); NodeList node = document.getElementsByTagName("metadata"); System.out.println("Information of Xml File"); System.out.println(xmlFile.substring(0, xmlFile.length() - 4)); //////////////////////////////////////////////////////////////////////////////////// String titleStoreText = ""; String descriptionStoreText = ""; String collectionStoreText = ""; String textToWrite = ""; //////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < node.getLength(); i++) { Node firstNode = node.item(i); if (firstNode.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) firstNode; NodeList titleElementList = element.getElementsByTagName("title"); Element titleElement = (Element) titleElementList.item(0); NodeList title = titleElement.getChildNodes(); //////////////////////////////////////////////////////////////////////////////////// if(titleElement == null) titleStoreText = " There is no title for this file."+ newLine; else titleStoreText = titleStoreText+((Node) title.item(0)).getNodeValue() + newLine; //titleStoreText = titleStoreText+((Node) title.item(0)).getNodeValue()+ newLine; //////////////////////////////////////////////////////////////////////////////////// System.out.println("Title : " + titleStoreText); NodeList collectionElementList = element.getElementsByTagName("collection"); Element collectionElement = (Element) collectionElementList.item(0); NodeList collection = collectionElement.getChildNodes(); //////////////////////////////////////////////////////////////////////////////////// if(collectionElement == null) collectionStoreText = " There is no collection for this file."+ newLine; else collectionStoreText = collectionStoreText+((Node) collection.item(0)).getNodeValue() + newLine; //collectionStoreText = collectionStoreText+((Node) collection.item(0)).getNodeValue()+ newLine; //////////////////////////////////////////////////////////////////////////////////// System.out.println("Collection : " + collectionStoreText); NodeList descriptionElementList = element.getElementsByTagName("description"); Element descriptionElement = (Element) descriptionElementList.item(0); NodeList description = descriptionElement.getChildNodes(); //////////////////////////////////////////////////////////////////////////////////// if(descriptionElement == null) descriptionStoreText = " There is no description for this file."+ newLine; else descriptionStoreText = descriptionStoreText+((Node) description.item(0)).getNodeValue() + newLine; //descriptionStoreText = descriptionStoreText+((Node) description.item(0)).getNodeValue() + newLine; //////////////////////////////////////////////////////////////////////////////////// System.out.println("Description : " + descriptionStoreText); //////////////////////////////////////////////////////////////////////////////////// textToWrite = "=====Title=====" + newLine + titleStoreText + newLine + "=====Collection=====" + newLine + collectionStoreText + newLine + "=====Description=====" + newLine + descriptionStoreText;// + newLine + "=====Subject=====" + newLine + subjectStoreText; //////////////////////////////////////////////////////////////////////////////////// } } ///////////////////////////////////////////write to file part is here///////////////////////////////////////// Writer output = null; File file2 = new File(xmlFile.substring(0, xmlFile.length() - 4)+".txt"); output = new BufferedWriter(new FileWriter(file2)); output.write(textToWrite); output.close(); System.out.println("Your file has been written"); //////////////////////////////////////////////////////////////////////////////////// } } catch (Exception e) { e.printStackTrace(); } } }

    Read the article

  • Why do I get a "warning: no newline at end of file" ?

    - by user198729
    The file is a helloworld.cpp: #include <iostream> using namespace std; int main() { if(true) cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! return 0; } But when I build it,get a warning: g++ -Wall -O2 -c -o hw.o hw.cpp hw.cpp:8:2: warning: no newline at end of file g++ -o myprog hw.o If I add a newline at the end,the warning will go. Why is that newline at end of file recommended in a cpp source file?

    Read the article

  • String vectors not working as expected with newline and iterators? (C++)

    - by kevin
    I have a text file made of 3 lines: Line 1 Line 3 (Line 1, a blank line, and Line 3) vector<string> text; vector<string>::iterator it; ifstream file("test.txt"); string str; while (getline(file, str)) { if (str.length() == 0) str = "\n"; // since getline discards the newline character, replacing blank strings with newline text.push_back(str); } // while for (it=text.begin(); it < text.end(); it++) cout << (*it); Prints out: Line 1 Line 3 I'm not sure why the string with only a newline was not printed out. Any help would be appreciated. Thanks.

    Read the article

  • About the leading newline in Visual Studio solution files.

    - by mafutrct
    Sometimes, for unknown reasons, VS 2008 creates solution files led by a newline. Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 [...] This happened on various machines, and I have no idea why this is. A Google search did not yield any useful results. Now, why do I worry about this? Because I can't open these solutions in Windows Explorer. I have to open VS, select File - Open - Solution and it works fine. But to open solutions from within Explorer, I have to edit the sln file and remove the leading newline. Edit: After Leom's suggestion I tested a few times and found that the issue is solely dependent on the leading newline.

    Read the article

  • How to search for newline or linebreak characters in Excel?

    - by Highly Irregular
    I've imported some data into Excel (from a text file) and it contains some sort of newline characters. It looks like this initially: If I hit F2 (to edit) then Enter (to save changes) on each of the cells with a newline (without actually editing anything), Excel automatically changes the layout to look like this: I don't want these newlines characters here, as it messes up data processing further down the track. How can I do a search for these to detect more of them? The usual search function doesn't accept an enter character as a search character.

    Read the article

  • how to display online each and every meta tags in newline ?

    - by Suma
    I want to display meta tags in newline means when i open a site and seeing the viewsource of the site the all meta tags is displayed in oneline. i want to display each and every meta tag in one newline. for ex: required output: <meta name="description" content="vvvv sdhgf dbngfsdj"> <meta name="keywords" content="dgd, sfdg, sdjgj"> but displayed output like this: <meta name="description" content="vvvv sdhgf dbngfsdj"><meta name="keywords" content="dgd, sfdg, sdjgj">

    Read the article

  • Putting newline in matplotlib label with TeX in Python?

    - by user248237
    How can I add a newline to a plot's label (e.g. xlabel or ylabel) in Matplotlib? For example, plt.bar([1, 2], [4, 5]) plt.xlabel("My x label") plt.ylabel(r"My long label with $\Sigma_{C}$ math \n continues here") Ideally i'd like the y-labeled to be centered too. Is there a way to do this? It's important that the label have both tex (enclosed in '$') and the newline. thanks.

    Read the article

  • How can I have a newline in a string in sh?

    - by juannavarroperez
    This STR="Hello\nWorld" echo $STR produces as output Hello\nWorld instead of Hello World What should I do to have a newline in a string? I'm aware of echo -e, but I'm no sending the string to echo, the string will be used as an argument by another command that doesn't know how to interpret \n as a newline.

    Read the article

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