Search Results

Search found 1545 results on 62 pages for 'manipulation'.

Page 28/62 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Splitting 25mb .txt file into smaller files using text delimiter

    - by user574141
    Regards, SO I am new to python and Perl. I have been trying to solve a simple problem and getting tied in knots with syntax. I hope someone has the time and patience to help. I have a 25mb file in ".txt" format which contains news-wire articles going back to 1970. Each news story is concatenated to the next, with only the "Copyright" statement to delimit. Each news story starts with "Item XX of XXX DOCUMENTS". There are certain metadata that are repeated throughout, I will use these for tagging later on. I wish to split this 25mb file into separate .txt files, each containing one news story (i.e. the text between "DOCUMENTS" and "Copyright", saving each with a different name (obviously). I am trying to 1 ) open the file... 2) iterate over lines in the file checking for the eof delimiter, and if it is not present writing the line to a list 3)write that list to a seperate small file. I'm having big problems with changing filenames using the counter, and how do I make Python start from where I left off, is the "seek" function appropriate? so far I have been trying this approach, completely unsuccessfully: myfile = open ("myfile.txt", 'r') filenumber = 0 for line in myfile.readline(): filenumber += 1 w=0 while myfile.readline() != '\s+DOCUMENTS\s*\n' ### read my line into a list mysmallfile()['w'] = [myfile.readline()] w += 1 output = open('C:\\Users\\dunner7\\Documents\###how do I change the filename each iteration???', 'w') output.writelines(mysmallfile) ###go back to start. Thank you for your time and patience. RD

    Read the article

  • ruby - find and replace in a string for commonly used street suffix

    - by go minimal
    The post office actually publishes a list of commonly used street suffixes in addresses: http://www.usps.com/ncsc/lookups/abbr_suffix.txt I want to take this list and make a ruby function that takes a string, takes the last word ("183 main strt".split[' '].last) and if it matches any of the commonly used street suffixes ("strt"), replace it with the official Postal Service Standard Suffix ("st"). Is there a better way to approach this than a massive str.sub.sub.sub.sub.sub?

    Read the article

  • manipulate variable made up of html before adding it to the dom (new in jQuery 1.4???)

    - by pedalpete
    I thought I had seen this in the first announcement of jQuery 1.4, but can't seem to find anything now. I have a calendar table which is built dynamically from a json ajax response. The table is built in a variable called putHtml. Currently, once the table is added to the DOM, I run a showEvents function which takes each event and adds it to the appropriate cell in the table. Unfortunately, when I have 100 events, that means I am updating the DOM 100 seperate times. Which is getting rather slow. I use the showEvents function to add events dynamically, so it would be really nice if I could just use the same function, and specify to look in the DOM for the cell to add the event to, or look in the variable (assuming I've got it right, and you can actually do this with jQuery). The code I use currenlty is this jQuery('div#calendars').append('putHtml.join('')); for(var e in thisCal.events){ showEvent(thisCal.events[e]); } What I had attempted to do instead was for(var e in thisCal.events){ showEvent(thisCal.events[e],putHtml); } jQuery('div#calendars').append('putHtml.join('')); the showEvents function looks like this function showEvents(event){ var eventDate=event.date; var eventTime=event.time; var eventGroup=event.group; var eventName=event.name; var eventType=event.type; var whereEvent=jQuery('div.a'+eventDate, 'table.'+eventGroup); var putEvent='<div class="event" id="a+'eventDate+'_'+eventTime+'">'+eventName+'</div>' jQuery(whereEvent, 'div#calendar').append(putEvent); if(eventType2){ jQuery(whereEvent, 'div#listings').append(putEvent); } } when attempting to manipulate the variable putHtml before adding to the dom, I was passing putHtml into the showEvent function, so instead of '(whereEvent, 'div#calendar'), I had (whereEvent, putHtml), but that didn't work. of course, the other method to accomplish this would be that when I make each cell, I iterate over the events json, and apply the appropriate html to the cell at the time, but that means repetitively running over the entire json in order to get the event to put in the cell. Is there another/better way to do something like this?

    Read the article

  • Rich image scroll and zooming on android

    - by F0RR
    I'm looking for a way to implement image zoom and scrolling the way it is implemented in Droid Comic Viewer. Is there any quick way to do that? If not, then could you please give some advices at least on implementing kinetic scrolling.

    Read the article

  • How do I select and group by a portion of a string?

    - by Russ Bradberry
    Given I have data like the following, how can I select and group by portions of a string? Version Users 1.1.1 1 1.1.23 3 1.1.45 1 2.1.24 3 2.1.12 1 2.1.45 3 3.1.10 1 3.1.23 3 What I want is to sum up the users using version 1.1.x and 2.2.x and 3.3.x etc, but I'm not sure how I can group on a partial string in a select statement. edit What the data should return like is this: Version Users 1.1.XX 5 2.1.XX 7 3.1.XX 4 There is an infinite variable number of versions, some are in this format (major, minor, build) some are just major, minor and some are just major, the only time I want to "roll up" the versions is when there is a build.

    Read the article

  • Need to get pixel averages of a vector sitting on a bitmap...

    - by user346511
    I'm currently involved in a hardware project where I am mapping triangular shaped LED to traditional bitmap images. I'd like to overlay a triangle vector onto an image and get the average pixel data within the bounds of that vector. However, I'm unfamiliar with the math needed to calculate this. Does anyone have an algorithm or a link that could send me in the right direction? I'm not even clear what this type of math is called. I've created a basic image of what I'm trying to capture here: http://imgur.com/Isjip.gif

    Read the article

  • How can I do the multiple replace in python?

    - by prosseek
    As asked and answered in HERE, I need to replace '[' with '[[]', and ']' with '[]]'. I tried to use s.replace(), but as it's not in place change, I ran as follows to get a wrong anwser. path1 = "/Users/smcho/Desktop/bracket/[10,20]" path2 = path1.replace('[','[[]') path3 = path2.replace(']','[]]') pathName = os.path.join(path3, "*.txt") print pathName -- /Users/smcho/Desktop/bracket/[[[]]10,20[]]/*.txt How can I do the multiple replace in python? Or how can I replace '[' and ']' at the same time?

    Read the article

  • How do I splice a python string programmatically?

    - by Robin Welch
    Very simple question, hopefully. So, in Python you can split up strings using indices as follows: >>> a="abcdefg" >>> print a[2:4] cd but how do you do this if the indices are based on variables? E.g. >>> j=2 >>> h=4 >>> print a[j,h] Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: string indices must be integers

    Read the article

  • Tear subString from within HTML tags with JAVA

    - by asaf
    Hi! let say i have a string like this "neverMindWhat is upneverMind" and I want to take out the What is up using regexp with JAVA. Someone told me that using matcher will be the best. Can anyone show me how to do it using Matcher? Other solutions are welcome too! Thanks!

    Read the article

  • Parse multiple filters in SQL

    - by Jeff Meatball Yang
    I have a problem parsing a stored procedure parameter in the form: declare @S varchar(100) set @S = '4=2,24=1534' Here's the query: select cast(idx as varchar(100)) 'idx' , value , SUBSTRING(value, 1, charindex(value, '=')+1) 'first' , SUBSTRING(value, charindex(value, '=')+1, LEN(value)-charindex(value, '=')-1) 'second' from Common.SplitToTable(@S, ',') -- returns (idx int, value varchar(max)) where len(value) > 0 But here is the result I get: idx value first second 0 4=2 4 4= 1 24=1534 2 24=153 Here's what I expected: idx value first second 0 4=2 4 2 1 24=1534 2 1534 Help?

    Read the article

  • How to process this string via regular expression

    - by iiduce
    my string style like this: expression1/field1+expression2*expression3+expression4/field2*expression5*expression6/field3 a real style mybe like this: computer/(100)+web*mail+explorer/(200)*bbs*solution/(300) "+" and "*" represent operator "computer","web"...represent expression (100),(200) represent field num . field num may not exist. I want process the string to this: /(100)+web*+explorer/(200)bbs/(300) rules like this: if expression length is more than 3 and its field is not (200), then add brackets to it.

    Read the article

  • rotate image with php - any degree

    - by Luis
    How to rotate an image with PHP, any degree, without having the filled space? For instance, if I rotate an image 10 degrees, the image rotates fine but the container around (square) gets filled with black. Is it possible to get rid of this, when for example merging 2 images?

    Read the article

  • Nokogiri find text in paragraphs

    - by astropanic
    I want to replace the inner_text in all paragraphs in my XHTML document. I know I can get all text with Nokogiri like this doc.xpath("//text()") But I want only operate on text in paragraphs, how I can select all text in paragraphs without affecting eventually existent anchor texts in links ? #For example : <p>some text <a href="/">This should not be changed</a> another one</a>

    Read the article

  • Pre-formatting text to prevent reflowing

    - by mattjn
    I've written a fairly simple script that will take elements (in this case, <p> elements are the main concern) and type their contents out like a typewriter, one by one. The problem is that as it types, when it reaches the edge of the container mid-word, it reflows the text and jumps to the next line (like word wrap in any text editor). This is, of course, expected behavior; however, I would like to pre-format the text so that this does not happen. I figure that inserting <br> before the word that will wrap would be the best solution, but I'm not quite sure what the best way to go about doing that is that supports all font sizes and container widths, while also keeping any HTML tags intact. I figure something involving a hidden <span> element, adding text to it gradually and checking its width against the container width might be on the right track, but I'm not quite sure how to actually put this together. Any help or suggestions on better methods would be appreciated.

    Read the article

  • How to grep lines having specific format.

    - by Nitin
    I have got a file with following format. 1234, 'US', 'IN',...... 324, 'US', 'IN',...... ... ... 53434, 'UK', 'XX', .... ... ... 253, 'IN', 'UP',.... 253, 'IN', 'MH',.... Here I want to extract only those lines having 'IN' as 2nd keyword. i.e. 253, 'IN', 'UP',.... 253, 'IN', 'MH',.... Can any one please tell me a command to grep it.

    Read the article

  • VB.Net Split A Group Of Text

    - by Ben
    I am looking to split up multiple lines of text to single them out, for example: Url/Host:ftp://server.com/1 Login:Admin1 Password:Password1 Url/Host:ftp://server.com/2 Login:Admin2 Password:Password2 Url/Host:ftp://server.com/3 Login:Admin3 Password:Password3 How can I split each section into a different textbox, so that section one would be put into TextBox1.Text on its own: Url/Host:ftp://server.com/1 Login:Admin1 Password:Password1 Thanks in advance :)!

    Read the article

  • String useless character strip - PHP

    - by Zoltan Repas
    Hi! I've got a huge problem. I made a special ID for the things in our webpage. Let's see an example: H0059 - this is the special ID called registration number. The last two chars are the things' id. I'd like to cut off the useless characters, to get the real ID, what means strip the first char, and all the 0s before any other numbers. (Example: L0745 = 745, V1754 = 1754, L0003 = 3, B0141 = 141, P0040 = 40, V8000 = 8000) Please help me in this. I've tried with strreplace and explode but failed :( Thanks for the help.

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >