f = open('transaction.log','r')
ClerkHash = dict()
arr = [0,0]
for line in f:
Tdate = line[0:12]
AccountKey = line[12:50]
TransType = line[22:2]
ClerkKey = line[24:10]
CurrencyCode = line[34:2]
Amount = line[36:45]
print line
print '\n'
print AccountKey
print '\n'
pri...
After I convert a decimal value salePr to string, using following code:
decimal salePr;
string salePrStr;
...
salePrStr = (salePr).ToString("0000.00");
'''
I'd like to get rid of leading zeros (in case result is <1000).
What is right and the best way to do this operation?
...
I have a string that looks like this:
"0.4794255386042030002732879352156"
which is approximately the sin(0.5). I would like to format the string to look a much nicer
"4.794255386042e-1"
How can I achieve this? Remember I am dealing with strings and not numbers (float, double). Also I need to round to keep the number as accurate as ...
"I have a List of objects with a property "CustomizationName".
I want to join by a comma the values of that property, i.e.; something like this:
List<MyClass> myclasslist = new List<MyClass>();
myclasslist.Add(new MyClass { CustomizationName = "foo"; });
myclasslist.Add(new MyClass { CustomizationName = "bar"; });
string foo = myclassl...
See Related .NET question
I'm looking for a quick and easy way to do exactly the opposite of split
Someith that will cause ["a","b","c"] to become "a,b,c"
Iterating through an array requires either adding a condition (if this is not the last element, add the seperator) or using substring to remove the last seperator
I'm sure there i...
Hi all, i am creating a python server socket that sends data to the client reguarding files status... what i have is a list containing dictionaries:
[{'Status': '[2,5%]', 'File': 'SlackwareDVD.iso'},
{'Status': '[21,8%]', 'File': 'Ubuntu_x86.iso'}]
the socket, when asked, sends this data, obviously it is sent as a string type.. i was...
I'm writing a custom highlight animation with Scriptaculous that includes a CSS3 glow. I get the box-shadow style and need to split it at the rgba alpha value, then vary that value to get the shadow to fade.
$('fresh').style.MozBoxShadow
would return
0 0 20px rgba(163, 238, 71, 1.0)
1.0 is the alpha value. I need to split it so tha...
I need to reformat a string using jquery or standard javascript
Lets say we have
Sonic Free Games
I want to convert it to
sonic-free-games
So white spaces replaced with dashes and all letters converted to small letters
Any help on this please ?
...
i am trying to verify strings to make valid urls our of them
i need to only keep A-Z 0-9 and remove other characters from string using javascript or jquery
for example :
Belle’s Restaurant
i need to convert it to :
Belle-s-Restaurant
so characters ’s removed and only A-Z a-z 0-9 are kept
thanks
...
Bash script
I have a string:
tcp 6 0 CLOSE src=111.11.111.111 dst=222.22.222.22 sport=45478 dport=5000 packets=7 bytes=474 src=111.11.111.111 dst=222.22.222.22 s
port=5000 dport=45478 packets=8 bytes=550 [ASSURED] mark=0 use=1
I need cut src IP addr 111.11.111.111,
how?
...
I've been reading Accelerated C++ and I have to say it's an interesting book.
In chapter 6, I have to use a function from <algorithm> to concatenate from a vector<string> into a single string. I could use accumulate, but it doesn't help because string containers can only push_back characters.
int main () {
using namespace std;
st...
The host that the majority of my script's users are on forces an text ad at the end of every page. This code is sneaking into my script's AJAX responses. It's an HTML comment, followed by a link to their signup page. How can I strip this comment and link from the end of my AJAX responses?
...
I have a DIV with some characters. How can I remove the last character from the text with each click on the DIV itself?
...
Assuming all you have is the binary data and no pre-canned functions, is there a pattern or algorithm to categorize the type of character?
...
Ok, i wrote 2 versions of this program. But im looking for the best solution - the most simple and fast one.
This is my solution but i was told that this solution is O(n*n) slower, which i dont know what really means. I was also told i could fasten it by breaking it into 2 functions, could anyone help me doing this?
void reverse3(char ...
Hi,
I am creating a request string which hast bo be formatted the following way:
http://staging.myproject.com?tags=tag1,tag2,tag3
There is an EditText dialog on the form where the user writes the tags. The user however can write the tags in the EditText whatever way he wants, for example using commas: tag1, tag2, tag3 or tag1,tag2,tag...
I am trying to solve the following problem but cannot find an elegant solution. Any ideas?
Thanks.
Input - a variable length string of numbers, e.g.,
string str = "5557476374202110373551116201";
Task - Check (from left to right) that each number (ignoring the repetitions) does not appear in the following 2 indexes. Using eg. above, Fir...
How does string expressions in C++ work?
Consider:
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
const char *tmp="hey";
delete [] tmp;
return 0;
}
Where and how is the "hey" expression stored and why is there segmentation fault when I attempt to delete it?
...
I hope somebody with better problem solving skills can help me out here. I have a textarea and all I had to do is split the text into 50 chars and feed the lines to another app. No problem. But I forgot about \n line breaks. If someone puts linebreak I have to also make that a seperate line. Here's my current code ($content is the origin...
I was about to write my own C# extension to convert a string to Proper Case (i.e. capitalize the first letter of every word), then I wondered if there's not a native C# function to do just that... is there?
...