TH339

1

votes
1

answer
342

views

How to display subscript letters in Django forms?

I have a very naive question. How to display subscripts in the Django form? For example, letters 'OC' are the subscripts. a. Is there a way to add some arguments in the label section? I have tried oc, but it was not recognized. b. should I try other functions rather than str ? Thanks for your help...
TH339
1

votes
1

answer
291

views

Dynamic forms in Django hosted by GAE

I am a newbie to Django, GAE, and met some problems when I am trying to build some dynamic forms using Django. The idea is that the selection made from one drop-down box determines value in another field. In detail, if an user choose 'A' in 'Species', then the value in the 'body_weight' will be 178....
TH339
1

votes
1

answer
726

views

jqplot generate plot using functions returned values

Sorry for this based question. I am fresh to jqplot and would like to use it to generate a bar graph based on data calculated from a function. Now, I have a parameter which holds data. Also, I have simple codes to generate a bar plot. So, can anyone give me a hint on how to link these two pieces to...
TH339
1

votes
2

answer
2.2k

views

jQplot line plot starts from x=0

I would like to create a line plot for a vector of y values. In the default situation, x should starts from 1. I am wondering is there a way to let x values start from 0? Below is my code and demo: $(document).ready(function() { var s= [12, 45, 89, 181, 111, 147, 116] $.jqplot('chart1',...
TH339
1

votes
1

answer
119

views

jQuery validate plugin validate inputs with similar names?

I am using jQuery validate to check my form before submitting. In my HTML, I have inputs with similar names, ids. I am wondering how to validate inputs with similar names without writing out one by one (something like jQuery select elements with similar names)? HTML Input 1: Input 2: Input 3: Javasc...
TH339
1

votes
1

answer
185

views

GAE mail API reply_to feature

I have a feedback form, where users can leave comments. These comments will be emailed to me and users' email address will appears as reply_to in the header, which means I can address these comments if I click the 'reply' button in the GMAIL. However, it seems like the 'reply-to' header does not wor...
TH339
1

votes
1

answer
788

views

Parse HTML uploaded CSV file in Python

I am using GAE to host a website which needs inputs from a CSV file. After this csv file has been uploaded, I will convert it to a table. However, I met the problem about Mac and Windows compatibility issue. The CSV file generated in Mac will not be recognized, and I got the error: new-line characte...
TH339
1

votes
1

answer
154

views

Customize Django Form

Have a basic question about how to show to tags in one within Django framework. I would like my HTML table looks like: HTML Table Object: Cell1 Cell2 Current Django code from django import forms class PFAMInp(forms.Form): Cell1 = forms.CharField(widget=forms.Textarea (attrs={'cols': 20, 'rows': 2}...
TH339
1

votes
2

answer
217

views

jQuery parse string data

My simulation results are acquired from REST service which contains strings and numerical values. I am able to parse the numerical ones (x_water), but have difficulties with the strings (x_date). Below is my approach, and I guess maybe I am wrong in using HTML5 data-val attribute to store strings. S...
TH339
1

votes
1

answer
383

views

Python read SAS generated XML type .xls file

I am trying to extract tabs from hundreds of SAS generated .xls files. I tried the following approach without luck. My version of xlrd is 0.9.2. import xlrd book = xlrd.open_workbook('out_1.xls') The error message is: Traceback (most recent call last):[Finished in 0.2s with exit code 1] File 'I:\Dr...
TH339
1

votes
1

answer
146

views

Python selenium selecting an invisible checkbox

I am trying to uncheck a checkbox using selenium in Python. However, I got the following error message: selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with I am wondering how should I make it visible? An interesting part...
TH339
1

votes
1

answer
771

views

Locate a mouseover element using Selenium in Python?

I am trying to locate an element (a h3 tag which only shows up by hovering onto it). After some search, it seems like ActionChains in selenium is the way to go. The code has two steps: 1: locate the mouseover object and hovering onto it. step 2: locate the new appread h3 tag. So far, Step 1 is fine....
TH339
1

votes
1

answer
95

views

How to efficiently assign values to a huge sparse matrix in R

I have a huge sparse with all zeros and I would like to replace some of its cells to value 1 based on indices from another matrix. Note that different cells will be replaced across columns and their indices are provided. I tried this on a sample data, and its quite slow. My real data has 1E8 rows. A...
TH339
1

votes
1

answer
294

views

Error 2042 (“N/A”) in Excel VLookup() Worksheet Function

Need some help to figure out strange VBA VLOOKUP Type Missmatch error. The code is really simple, since sss0 is a random number and all I want is to find closest value in a range (sheet 'BMD_CDF', Range('A2:B999')). In the spreadsheet, I set format for Sheets('BMD_CDF').Range('A2:B999') to scientifi...
TH339
1

votes
2

answer
5.2k

views

Call a DOS executable file from Python

Sorry if this question has been asked many times. I have a DOS .exe file. It works well by double clicking it in Windows, which generates some output files in the working folder. However, I need to call it from Python. I have tried the following commands (subprocess.Popen and os.system), but it only...
TH339
1

votes
1

answer
883

views

How to kill a process created by Python subprocess.Popen()

I need to call a DOS .exe file from Python and delete this .exe after the computation. I am able to call it using subprocess.Popen and os.system, however, I could not delete this .exe file if it is called by subprocess.Popen. The error is WindowsError: [Error 5] Access is denied. Can anyone let me k...
TH339
1

votes
1

answer
1.1k

views

jqplot label one point on the plot

I have a figure including two lines (one horizontal line, and one parabolic curve), and I would like to show the value of the crossing over point as well as label it with text 'MSY'. I tried to use the option pointLabels, but it seemed like I did not find the right way. Can anyone give me some hints...
TH339
1

votes
2

answer
1.8k

views

Import a number of csv files and replace NA by Zeros

I know how to do this individually. However, I have more than 1000 files. I decided to use a for loop. However, it seems like I did not find the correct way to evaluate my variables. Here is my code setwd('C:/data') filenames=dir() #find file names for (i in filenames){ adt = substr(x = i, start = 1...
TH339
1

votes
1

answer
1.6k

views

Read a CSV file in R, and select each element

Sorry if the title is confusing. I can import a CSV file into R, but once I would like to select one element by providing the row and col index. I got more than one elements. All I want is to use this imported csv as a data.frame, which I can select any columns, rows and single cells. Can anyone giv...
TH339
1

votes
1

answer
2.1k

views

Using macro and array to lag a group of variables in SAS

I tried to use macro and array to lag a bunch of variables by groups (id). my steps are: 1. lag all variables (groups not matter) 2. replace mis-lagged cells by . but I found my code is buggy and appreciate any suggestions. Here is the data: data old; input id sale capx profit; datalines; 1 11 11...
TH339
1

votes
2

answer
1.4k

views

Shiny R Zip multiple PDFS for download

I am sorry if this too simple... I need to zip a number of generated pdfs for uses to download. I tried to use Zip function, but failed with error: Warning: running command ''zip' -r9X 'pdfs.zip' 'plot_1.pdf' 'plot_2.pdf' 'plot_3.pdf' 'plot_4.pdf' 'plot_5.pdf' ' had status 127 Error opening file: 2...
TH339
1

votes
2

answer
160

views

Python Web Crawler for JavaScript Generated URLs

I am trying to use some Python web crawler to download about 3000 PDFs from a website. However, the URLs of those PDFs are generated by JavaScript function. So, I am wondering if there is any tutorial on how to achieve this? For example, the URL linked to Alberto European Hairspray (Aerosol) - All V...
TH339
1

votes
1

answer
1.3k

views

Remove Double Quotes While Reading CSV Files in VBA

In VBA, I need to import a few R generated CSV files. However, the split function did not work properly and gaveType mismatch. My best guess is that: VBA added double quotes between each imported line. So the first line becomes ' 47.27284, 130.5583, 44.826609, 189.905367'. I tried to remove double...
TH339
1

votes
1

answer
498

views

R set.seed does not produce consistent results

I am using a main R function to call a series of R functions from different scripts. In order to reproduce results, I set.seed in the beginning of my main script. In the code, sample() function to randomly select a couple of rows from a dataframe in function_8, and rand() in function_6. So a simple...
TH339
1

votes
1

answer
222

views

How to enable backpressure in Spark Streaming (using pyspark)

I would like know what would be the correct way of enable backpressure in spark streaming through pyspark. It looks like I have too many messages sent from Kafka in a short time and explode to it. Below is my code for spark streaming. Can anyone point me to the correct place to enable back pressure?...
TH339
1

votes
1

answer
138

views

Can PiCloud hold FORTRAN code? (website hosted by GAE)

I have a some old Fortran77 codes, which does some calculations. Now I build a website hosted by Google App Engine, and need to call those models' calculation results. Since I am new to both GAE and PiCloud, my basic questions are: Should I first compile those Fortran77 code using a windows compiler...
TH339
1

votes
1

answer
2.4k

views

Call a subprocess

I have to call an executable file in Ubuntu... Just learned how to make this work by using subprocess.Popen in windows. Now, I need to repeat this step in Ubuntu. I have used the following Python command: a=subprocess.Popen('filename.exe',shell=0) The return is Traceback (most recent call last): Fi...
TH339
1

votes
2

answer
4.8k

views

Problems using multipart_encode (poster library)

I am trying to upload a file using multipart_encode to realize the MIME process. However, I met the following error AttributeError: multipart_yielder instance has no attribute '__len__'. Below are is my approach, I really appreciate if anyone can give me some suggestions. url = 'https://pi-user-file...
TH339
1

votes
2

answer
191

views

Python change function input name internaly

I need to create a function which can: Inspect input arguments and get the number of inputs and their values Create a loop, and add string '_in' after each input name Make the new inputs global Assign new inputs with old values I tried to use inspect.getargspec() but it seems like this should be c...
TH339
1

votes
3

answer
3.1k

views

SAS proc univariate for many variables by macro or array

This should be an easy question, but I didn't figure out... I want to get mean and median of many variables by proc univariate as below. It's really time consuming to manually add M_ for mean and MD_ for median to all variables. I am wondering if there any simple approach, such as array to do so? T...
TH339
1

votes
1

answer
3.6k

views

How to escape in HTML5 data-attribute

The data-attribute stuff is new to me and just realized I need to escape space, comma, etc. Can anyone give me some suggestions on my approach? Below is my code: #A list holds all the strings to be sent to data-attribute, #the sequence and length of the list is dynamic, determined by the user #(Th...
TH339
1

votes
2

answer
764

views

jQuery validation plugin checks drop-down, scientific, and elements with similar names

This post is based on my previous question. I had a form with three sections, and use back and next button to hide and show users only one table section at a time. In addition, the next button also serves as validation trigger. My question is: My validation approach failed to check the drop down fi...
TH339
1

votes
2

answer
1.8k

views

jQuery add or remove table row based on inputs

Sorry, if this is too basic. I am trying to add rows to a table if current number of rows are less than a user's demand. At the same time, I need to delete the extra rows if current number of rows are more than a user's need. My code is working, but I think it does not make a lot of sense. So I am...
TH339
1

votes
2

answer
1.9k

views

How to get seleced values by jQRangeSlider

I am trying to integrate jQRangeSlider into my jqplot applications, which means users can slide the x axis and decide the range of plots to be illustrated. However, I am having some difficulties of accessing the selected range. Here is a demo of my approach. It seems like selected values are saved...
TH339
6

votes
2

answer
5.7k

views

Pandas equivalent rbind operation

Basically, I am looping through a bunch of CSV files and in the end would like to append each dataframe into one. Actually, all I need is an rbind type function. So, I did some search and followed the guide. However, I still could not get the ideal solution. A sample code is attached below. For inst...
TH339
1

votes
1

answer
1.9k

views

How to change xticks locations and customize legend using levelplot (lattice library)

I am trying to move the position of x-ticks and x-labels from the bottom of the figure to its top. In addition, my data has a bunch of NAs. Currently, levelplot just remove them and leave them as white space in the plot. I wondering if it is possible to add this NAs to the legend as well. Any sugge...
TH339
5

votes
1

answer
1.5k

views

Alternatives for running SciPy on Google App Engine?

I need to run some statistical tests in my app, which needs functions from scipy.stats. However I found Google App Engine doesn't trust SciPy. So is there any GAE supported libraries which can do some stats calculations e.g. generate random numbers, estimate CDF, run T-tests, check normality, etc....
TH339
4

votes
1

answer
268

views

VBA could find R library

I am trying to use EXCEL as the front end for a R script. So far, I tested my R script in Windows CMD but I could not make it work in VBA. The error message is Error in library(readxl) : there is no package called 'readxl'. So it looks like VBA environment is picky. Any suggestions on fixing this e...
TH339
5

votes
1

answer
2.1k

views

How to add model forms by Django in Google app engine?

I have built a website based on Google App Engine. It includes ten models, doing some simple calculations based on user inputs. Previously, it was coded using Python 2.5 using djangoform.modelform and db.model to handle data. Since Python 2.7 does not support djangoform.modelform, I would like to us...
TH339
2

votes
1

answer
1.9k

views

Cleaning up large XML files in Python (stream parse)

I tried to use Python to cleanup some messy XML files, which does three things: Converting 40%-50% tag names from upper case to lower case Removing NULL between tags Removing empty rows between tags I did this in using BeautifulSoup, however, I ran into memory issues since some of my XML files are o...
TH339

View additional