[Solved] Sorting multiple rows as a single column using Python.

import re import csv with open(‘data.txt’) as f: data = [] for line in f: items = re.split(‘[\s]+’, line.strip()) if not line.strip().startswith(‘K1’): data.append([]) data[-1].extend([items[0]] + items[2:]) else: data[-1].extend(items[1:]) data = list(map(list, zip(*data))) with open(‘data.csv’, ‘w’) as f: writer = csv.writer(f) writer.writerows(data) And your csv data looks like this: -29-,-30-,-31-,-32-,-33-,-34-,-35-,-36-,-37- 4.2735E+05,9.2186E+05,9.4197E+05,9.4089E+05,9.4889E+05,9.5109E+05,9.6455E+05,9.4382E+05,-4.8051E+06 4.3904E+05,9.2199E+05,9.4200E+05,9.4070E+05,9.4904E+05,9.5097E+05,9.6459E+05,9.4314E+05,-2.1630E+07 4.5718E+05,9.2134E+05,9.4127E+05,9.4016E+05,9.4849E+05,9.5042E+05,9.6377E+05,9.4290E+05,-8.8415E+07 4.8817E+05,9.2164E+05,9.4106E+05,9.4026E+05,9.4857E+05,9.5052E+05,9.6384E+05,9.4317E+05,-2.3794E+08 5.4312E+05,9.2075E+05,9.4132E+05,9.4015E+05,9.4842E+05,9.5047E+05,9.6355E+05,9.4365E+05,-5.2223E+08 7.3055E+05,9.1836E+05,9.4327E+05,9.3932E+05,9.4797E+05,9.4989E+05,9.6521E+05,9.4070E+05,-1.7084E+09 … Read more

[Solved] I want to sort the score in my json file from highest to lowest using java script

Try this var items= { “people”: [ { “name”: “Person A”, “score”: 100 }, { “name”: “Person B”, “score”: 101 }, { “name”: “Person C”, “score”: 100000 }, { “name”: “Person D”, “score”: 555 } ] }; items.people.sort(function(a, b){ return a.score – b.score; }); console.log(items); it works as expected! 0 solved I want to sort … Read more

[Solved] how to start the forloop.counter from a different index

I’m not comfortable with Django, so I show a couple of option in plain Python, given the collections: something1 = [1,2,3,4] something2 = [1,2,3,4,5,6,7,8,9,10] You can access objects by index (not the same as database index): i = 1 for e1 in something1: print(e1) i += 1 for i2 in range(i,len(something2)): print(something2[i2]) Or slice the … Read more

[Solved] Updating ArrayList with onlick not working

You’ve two arrayList one local and another one global. onClick() method you’re adding your item in global arrayList having reference name fruits but your ListView using local arrayList also having same name fruits, so don’t create local list inside onCreate() method. Also after adding new fruit call notifyDataSetChanged() on your adapter. ArrayList<String> fruits; ListAdapter myAdapter; … Read more

[Solved] Setting a PHP cookie value to be intentionally vulnerable

i looked at it again, try this: $cookie_name=”Authenticated”; // this checks if the value has been set already if (!isset($_GET[‘cookie_value’])) { // if no value is set, it defaults to 0 and displays the error message $cookie_value=0; $error = “You are not authorized to view this page!”; echo $error; } // Now here if the … Read more

[Solved] Change color in RGB images

I have to agree with Majid Shirazi regarding the proposed solution by Quang Hong. Let’s have a look at: idx = np.where(img == (0.4, 0.4, 0.4)) Then, idx is a 3-tuple containing each a ndarray for all x-coordinates, y-coordinates, and “channel”-coordinates. From NumPy’s indexing, I can’t see a possibility to properly access/manipulate the values in … Read more

[Solved] group by sum and join giving duplicate rows

You are getting duplicates due to join, you can get expected results without join. Try below query select materialno, sum(billedqty), min(materialdesc), min(startdate) from billing group by materialno; When you are joining test1 with billing table, you are getting duplicates because your materialno=”1001″ is having 2 corresponding “materialdesc” values, and “startdate” values. But the query I … Read more

[Solved] TypeError: ‘float’ object cannot be interpreted as an index, how to solve it?

can you write in your question an example of what the values of pts[0], pts[1], pts[2] looks like? if the values are close to integers (like 1.00004 or 3.9998) you can use the round function to round the values to the nearest integer like: data = array(data, ‘f’).reshape(round(pts[2]), round(pts[1]), round(pts[0])) solved TypeError: ‘float’ object cannot … Read more

[Solved] Separate a row of strings into separate rows [closed]

Python Power Unleased : import csv,sys filename=”a.csv” with open(filename,’rb’) as csvfile: reader = csv.reader(csvfile,delimiter=”,”) try: for row in reader: if row[1].find(‘,’) == -1: line=”,”.join(row) print line else: for i in range(0,row[1].count(‘,’)+1): line = row[0]+’,’+row[1].split(‘,’)[i]+’,’+row[2].split(‘,’)[i] print line except csv.Error as e: sys.exit(‘file %s, line %d: %s’ % (filename, reader.line_num, e)) solved Separate a row of strings … Read more

[Solved] using instr to find values in vba

You can try this: Sub find() Dim x As String, i As Long, lastrow As Long, y As Long Dim sh1 As Worksheet, sh2 As Worksheet Set sh1 = Sheets(“Sheet1”): Set sh2 = Sheets(“Sheet2”) x = “ra01” With sh1 lastrow = .Range(“F” & .Rows.Count).End(xlUp).Row For i = 2 To lastrow If InStr(.Range(“F” & i).Value, x) … Read more

[Solved] Second AJAX call to one div element not working

The jQuery function takes one function to execute on the document ready event, not two: jQuery( function() { $(“#profEdit”).click(function() { $(“#profInfo”).load(“profile_edit_info.php”); }); $(“#profEditDone”).click(function() { $(“#profInfo”).load(“profile_info.php”); }); } ); Chances are it was simply ignoring the second function because it doesn’t expect a second function parameter after executing the first one. Note also that if these … Read more

[Solved] Excel button that writes down the time of clicking

Create a new module in your VBE and stick this in there: Sub capturetime() Dim timeWS As Worksheet Dim timeRange As Range ‘Change “Sheet3” to whatever worksheet is your click log Set timeWS = ThisWorkbook.Sheets(“Sheet3”) ‘find the last cell in column A of your log Set timeRange = timeWS.Range(“A” & timeWS.Rows.Count).End(xlUp).Offset(1) ‘Write which button was … Read more

[Solved] Displaying random images on websites [closed]

you can’t randomized image with html , you have to use java script or css5 try this window.onload = choosePic; var myPix = new Array(“images/lion.jpg”,”images/tiger.jpg”,”images/bear.jpg”); function choosePic() { randomNum = Math.floor((Math.random() * myPix.length)); document.getElementById(“myPicture”).src = myPix[randomNum]; } solved Displaying random images on websites [closed]