I wrote a code the other day that worked fine up till now. However, it appears that it is not running anymore for unkown reasons.
Basically, I am copying a range from workbook called Data.xlsm (several tabs) to Masterfile.xlsm (on first tab).
Code looks as follows:
Sub CopyingRange()
' Set dimensions
Dim x As Workbook
Dim y As Workbook
' Set Workbook
Set x = Workbooks.Open("C:\Users\...\Data.xlsm")
Set y = Workbooks.Open("C:\Users\...\Masterfile.xlsm")
'Now, transfer values from x to y:
Workbooks("Data").Sheets("Andorra").Range("L123:O123").Copy Range("T3")
Workbooks("Data").Sheets("Angola").Range("L123:O123").Copy Range("T4")
Workbooks("Data").Sheets("Austria").Range("L123:O123").Copy Range("T5")
Workbooks("Data").Sheets("Bahrain").Range("L123:O123").Copy Range("T6")
Workbooks("Data").Sheets("Belgium").Range("L123:O123").Copy Range("T7")
Workbooks("Data").Sheets("Botswana").Range("L123:O123").Copy Range("T8")
End Sub
Related
The fit addon causes a line in xtermjs to overwrite previous lines. Specifically, when the user types, half a line is filled up, and then the characters begin appearing from the left hand side of the line and overwriting the previous characters written there.
const fitAddon = new FitAddon.FitAddon()
term.loadAddon(fitAddon)
fitAddon.fit()
This happens when the columns of xterm and columns of your serverside PTY are not equivalent. You can change the xterm columns and rows like this.
const term = new Terminal({
rows: x,
cols: y,
});
Where x and y are your PTY rows and columns.
I have a spreadsheet containing data in lines on several sheets. These sheets are named arbitrarily (not sheet1 sheet2 nor any similar scheme).
I need to extract some info from one of the lines of the current sheet (I give the number of the line in an input box), then put this info on another sheet to format it, then print that formatted sheet, and finally go back to the initial sheet I was on (one of those containing data).
So far I have come up with this code: (I omit the line selection and data copying because that works)
' Sheets("facture").PrintOut
Dim oDoc as Object
oDoc=ThisComponent
Dim sPrefix$ ' Prefix used to identify the print listener routines.
Dim sService$ ' Print listener service name
sPrefix="print_listener_"
sService="com.sun.star.view.XPrintJobListener"
If NOT oDoc.sheets().hasByName("facture") Then
MsgBox "Le document n'a pas de page nommée 'facture'"
Else
Dim oSheets
oSheets = oDoc.Sheets
Dim currentSheet
currentSheet = oDoc.getcurrentcontroller.activesheet
oDoc.currentController.setActiveSheet(oSheets.getByName("facture"))
oPrintListener=CreateUnoListener(sPrefix,sService)
oDoc.addPrintJobListener(oPrintListener)
'oPrintJobListnerDoc=oDoc
oDoc.Print(Array())
wait 12000
oDoc.currentController.setActiveSheet(currentSheet)
However, when I run it, the data is correctly formated on my output sheet, but the VB window pops up with 'BASIC runtime error: property or meethod not found: $(ARG1)'.
If I remove the 'wait 12000' and 'oDoc.currentController.setActiveSheet(currentSheet)' then the data is printed correctly but Calc stays on the output sheet, and doesn't get back tot the initial sheet I was on (obviously).
If I only remove the 'wait 12000', nothing happens, and the data is not printed.
Can anybody help? Thanks!
The general principle of waiting for the end of printing can be expressed as follows
REM ***** BASIC *****
Public Statex1 As Integer ' Through this variable, the event handling procedure will notify the main program
Public oPrintJobListnerDoc As Variant
Sub PrintOutFacture()
Dim oDoc As Variant
oDoc=ThisComponent
Statex1=0
oPrintJobListnerDoc = CreateUnoListener("print_listener_", "com.sun.star.view.XPrintJobListener")
oDoc.addPrintJobListener(oPrintJobListnerDoc)
Rem ...Prepare the print - fill the cells with the desired values, format, define the print area, etc.
oDoc.Print(Array()) ' It might not be an empty array, but a whole bunch of print options!
While Statex1=0 ' 1 = Printing completed, 3 = Print canceled
Wait 100
Wend
oDoc.removePrintJobListener(oPrintJobListnerDoc)
Rem ...Post-Print Actions - Switch the sheet, close the document, or do something else
End Sub
Sub print_listener_printJobEvent(oEvent As Variant)
Statex1 = oEvent.State ' Pass the value of the State field of the oEvent to the main program through the Public variable Statex1
End Sub
Sub print_listener_disposing
End Sub
I want to plot two time series that are in different formats in the
same format, but one of those two doesn't work for me.
So here's the thing:
I have a time series in seconds with a given starting time t0.
So the series looks like this:
Starting time: t0
0 -21.0028
5 -21.0067
10 -21.007
...
17875 -20.9943
I want to plot this time series with the time (e.g. 9:03) instead
of seconds and I want to show another time series where the
data is given in standard time in the same plot.
I can plot the second series just fine.
But when I try to plot the first series, the measured points
start jumping from x=100 back to 0 and then back and forth.
Additionally I can't add the offset t0 to the series.
Here's what I tried (t0 = 32615s) to get at least the first time series plotted:
gnuplot> set xdata time
gnuplot> set timefmt "%S"
gnuplot> set format x "%H:%M"
gnuplot> plot 'measurement.dat' u (timecolumn(1)+32615):2 w l, 'measurement2.dat" u 1:2 w l
Does anyone know how I can plot these time series?
Thanks in advance!
My understanding of your problem is that you have two data sets with different timedata. One in seconds and the other what you call "standard", I assume, e.g. 09:03:00.
And you want to shift the one with seconds by some value.
Internally, dates and times are stored as seconds from January 1st 1970 00:00:00.
Since the first dataset is already in seconds just add your shift-value.
You need to convert ´$Data2´ into seconds via timecolumn(1,"%H:%M:%S").
And the way you display the xtic labels is set via set format x "%H:%M" time. Also check help timecolumn. It also depends if you want to display a time of the day, i.e. 00:00 to 23:59 or if you want to display hours >24h. Then you might want to use "%tH:%tM:%tS"as format. Check help time_specifiers.
Code:
### shifted time data
reset session
# create some test data
set print $Data1
do for [i=1:20000:200] {
print sprintf("%d %.3f",i,sin(i/2000.))
}
set print
set print $Data2
do for [i=30000:50000:200] {
print sprintf("%s %.3f",strftime("%H:%M:%S",i),2*sin(i/2000.-2.5))
}
set print
set format x "%H:%M" time
set key top center
set multiplot layout 2,1
plot $Data1 u 1:2 w lp ti "Data1", \
$Data2 u (timecolumn(1,"%H:%M:%S")):2 w lp ti "Data2"
t0 = 30000
plot $Data1 u ($1+t0):2 w lp ti "shifted Data1", \
$Data2 u (timecolumn(1,"%H:%M:%S")):2 w lp title "Data2"
unset multiplot
### end of code
Result:
I have a file with more than 250 variables and more than 100 cases. Some of these variables have an error in decimal dot (20445.12 should be 2.044512).
I want to modify programatically these data, I found a possible way in a Visual Basic editor provided by SPSS (I show you a screen shot below), but I have an absolute lack of knowledge.
How can I select a range of cells in this language?
How can I store the cell once modified its data?
--- EDITED NEW DATA ----
Thank you for your fast reply.
The problem now its the number of digits that number has. For example, error data could have the following format:
Case A) 43998 (five digits) ---> 4.3998 as correct value.
Case B) 4399 (four digits) ---> 4.3990 as correct value, but parsed as 0.4399 because 0 has been removed when file was created.
Is there any way, like:
IF (NUM < 10000) THEN NUM = NUM / 1000 ELSE NUM = NUM / 10000
Or something like IF (Number_of_digits(NUM)) THEN ...
Thank you.
there's no need for VB script, go this way:
open a syntax window, paste the following code:
do repeat vr=var1 var2 var3 var4.
compute vr=vr/10000.
end repeat.
save outfile="filepath\My corrected data.sav".
exe.
Replace var1 var2 var3 var4 with the names of the actual variables you need to change. For variables that are contiguous in the file you may use var1 to var4.
Replace vr=vr/10000 with whatever mathematical calculation you would like to use to correct the data.
Replace "filepath\My corrected data.sav" with your path and file name.
WARNING: this syntax will change the data in your file. You should make sure to create a backup of your original in addition to saving the corrected data to a new file.
I have a pyscript that I am working on and running into issues with the legend.
The goal of the script is to take a csv file with two columns (country, value) that I am joining to a world map based on country name. Once they are joined I turn it into a lyr file and then start to work on the mapping aspects of it.
I want to change the field being mapped to 'value' and then change the mapping to graduated symbols with 5 breaks (at 5,20,50,75,100 % of the max value in the map). The problem being that depending on what layer file is being used the max value changes. I have spent a lot of time searching for how to do this and have still come up short, there are probably some unnecessary bits to my code as well as I am now to python.
How can I get it to map based on graduated symbol based on 5 percent breaks with a changing max value?
Some of the code I have been working on below,
import os, sys, string, arcpy, arcpy.mapping, glob, arcgisscripting,time
from arcpy import env
call blank mxd file, set feature layer, Declare variables
mxd = arcpy.mapping.MapDocument(workspace/blank_4.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
'newname' is the layer file being used
sourceLayer = arcpy.mapping.Layer(newname)
Convert feature classes to layer objects
outLayer = str(newname)
curmap = workspace + filename + ".shp"
arcpy.MakeFeatureLayer_management(curmap, outLayer)
Save layer objects to layer files
LayerFile = str(outLayer) + ".lyr"
arcpy.SaveToLayerFile_management(outLayer, LayerFile)
Define variable for the new layer using LayerFile object
newlayer = arcpy.mapping.Layer(LayerFile)
Adds the new layer to top of TOC in the mxd doc map document
arcpy.mapping.AddLayer(df, newlayer, "TOP")
change the mapping field from country name to fert value
lyr = arcpy.mapping.ListLayers(mxd, newlayer, df)[0]
symbols = arcpy.mapping.Layer(C:\workspace\graduated_symbol2.lyr")
graduated symbols is a blank layer file where I created a legend with 5 breaks (5,20,50,75,100 %) but the range was created based on a max value of 22,000 and now when I run a file with a max value of 35,000 anything above 22,000 becomes blank.
How can I get it to purely work on % breaks, and have the 0/max range of the respective csv file be used??????
Update new layer with sybmology from the source layer
arcpy.ApplySymbologyFromLayer_management(lyr,symbols)
arcpy.mapping.UpdateLayer(df, lyr, symbols, True)
change symbology, colors, and breaks
if lyr.symbologyType == "GRADUATED_COLORS":
lyr.symbology.valueField = "value"
print lyr.symbology.numClasses #
Then I output this to a pdf, but that part is working.
Thanks!