How to change comments in excel file with go - go

I'm using the excelize library.
newfile, _ := excelize.OpenFile("filename.xlsx")
println(newfile.GetComments())
//map[Sheet1:[{Author 0 A2 comment1}]]
_ = newfile.InsertRow("Sheet1", 1)
println(newfile.GetComments())
//map[Sheet1:[{Author 0 A2 comment1}]]
the coordinates of my comment comment1 have not changed. How to solve this problem?

Related

VBA Compile Error: For Control Variable already in use

I am trying to write a triple nested for loop and I get the error message "For Control Variable already in use". I have dimmed and set all the my variables, but it is my first time using a triple nested loop and I can't understand why there is an error. Below my code:
Dim LastrowProv As Integer
Dim LastRowAdv As Integer
LastrowProv = Worksheets("Provisions").Cells(1, 1).End(xlDown).Row
LastRowAdv = Worksheets("Advances").Cells(1, 1).End(xlDown).Row
LastRowCPMatch = Worksheets("Exclusions").Cells(1, CPMatch).End(xlDown).Row
For z = LastRowCPMatch To 1 Step -1
For x = LastrowProv To 2 Step -1
For i = LastRowAdv To 2 Step -1
If Worksheets("Advances").Cells(i, CPNameAdv) = Worksheets("Exclusions").Cells(z, CPMatch) _
And Worksheets("Provisions").Cells(x, CPNameProv) = Worksheets("Exclusions").Cells(z, CPMatch) _
And Worksheets("Advances").Cells(i, IntEntAdv) = Worksheets("Provisions").Cells(x, IntEntProv) _
And Worksheets("Advances").Cells(i, TExpAdv) > -Worksheets("Provisions").Cells(x, TExpProv) Then
Worksheets("Advances").Cells(i, TExpAdv) = Worksheets("Advances").Cells(i, TExpAdv) + Worksheets("Provisions").Cells(x, TExpProv)
Worksheets("Advances").Cells(i, UnsExpAdv) = Worksheets("Advances").Cells(i, UnsExpAdv).Value + Worksheets("Provisions").Cells(x, UnsExpProv).Value
Worksheets("Provisions").Rows(x).EntireRow.Delete
Exit For
End If
Next i
Next x
Next z
Thank you for the help!

How to loop through a folder with conditional statement in Stata?

I have a folder with a bunch of csv files and I want to loop through each file, check if a list of variables in each of the files = 0, then save the csv file as a .dta if they do not equal 0.
I'm having trouble finding online help to do this but here's what I've tried so far:
foreach file in `files' {
import delimited using `file', clear
if a & b & c & d != 0
save "Desktop\myfolder\`file'.dta"
}
when I try this though Stata tells me "{ required r(100)".
Any help appreciated. Thanks.
Stealing some code from the estimable #Wouter Wakker, let's first suppose that the criterion is that a non-zero value is found somewhere in a b c d
foreach file in `files' {
import delimited using `file', clear
local OK = 0
quietly foreach v in a b c d {
count if `v' != 0
if r(N) > 0 local OK = 1
}
if `OK' save "Desktop/myfolder/`file'.dta"
}
Whatever your precise criterion, I think you need to loop over a b c d and (say) count or summarize according to what you want or do not want.
From help ifcmd:
Syntax
if exp { or if exp single_command
multiple_commands
}
So you can do either
foreach file in `files' {
import delimited using `file', clear
if a & b & c & d != 0 save "Desktop\myfolder\`file'.dta"
}
or
foreach file in `files' {
import delimited using `file', clear
if a & b & c & d != 0 {
save "Desktop\myfolder\`file'.dta"
}
}
However, I don't think your if condition does what you think it does. What you're looking for would rather be:
if a != 0 & b != 0 & c != 0 & d != 0

Figuring out different CoNLL format

I am trying to generate a conll file from Stanford Core NLP, which then can be used as an input to Semafor (as semafor accepts conll file only).
The generated file looks like this:
1 My my PRP$ O 2 nmod:poss
2 kitchen kitchen NN O 5 nsubj
3 no no RB O 4 neg
4 longer longer RB O 5 advmod
5 smells smell VBZ O 0 ROOT
6 . . . O 5 punct
When I use this file, the Semafor server returns illegalArgument exception since the format is slightly different. Their example conll file looks like this:
1 My _ PRP$ PRP$ _ 2 NMOD _ _
2 kitchen _ NN NN _ 5 SBJ _ _
3 no _ RB RB _ 5 ADV _ _
4 longer _ RB RB _ 3 AMOD _ _
5 smells _ VBZ VBZ _ 0 ROOT _ _
6 . _ . . _ 5 P _ _
It seems that I can control the output by defining the keys. The default keys are ID, FORM, LEMMA,POSTAG,NER, HEAD, DEPREL. However, I don't know the keys for the example conll file provided by Semafor. Please guide me how I might convert the generated file format into Semafor example file format.
I believe that Semafor can generate its own conll file in the format that it needs. We use Stanford Core NLP just to split a document into sentences per line, and then use Semafor itself to generate the conll file.

Sub line gives compile error: variable not defined

Upon trying to run my code I get the error "compile error: variable not defined" and it highlights my Sub line. Here is the code for reference.
Sub RI_Processing()
Dim i As Single
Dim Output() As Single 'Define this dynamic array for the solver output
Process the DMSO data
For i = 1 To 45 Step 1
Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Activate
RawData.Range("C10:C649") = Sheet1.Columns("i").Values
SolverOk SetCell:="$E$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$2:$B$4", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve
Workbooks("Simulated Fresnel Function.xlsx").Activate
Output(i, 1) = Sheet1.Range("B4").Values
Next i
i = 0
' Process the NaCl Data
For i = 1 To 102 Step 1
Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Activate
RawData.Range("C10:C649") = Sheet2.Columns("i").Values
SolverOk SetCell:="$E$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$2:$B$4", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve
Workbooks("Simulated Fresnel Function.xlsx").Activate
Output(i, 2) = Sheet1.Range("B4").Values
Next i
i = 0
' Process the Sucrose data
For i = 1 To 72 Step 1
Workbooks("Calibration Range 1 Normalized Profiles.xlsx").Activate
RawData.Range("C10:C649") = Sheet3.Columns("i").Values 'Copies the data of all 'i' columns to raw data for solver
SolverOk SetCell:="$E$7", MaxMinVal:=2, ValueOf:=0, ByChange:="$B$2:$B$4", _
Engine:=1, EngineDesc:="GRG Nonlinear"
SolverSolve 'Run solver
Workbooks("Simulated Fresnel Function.xlsx").Activate
Output(i, 3) = Sheet1.Range("B4").Values 'Put solver output to the matrix 'output' in the appropriate columns
Next i
End Sub

Advise on this . My code has some blocker.i am getting the error 'object required'

I am using the functions below.In the first one i have parsed the node of xml and its value using MSXML. similar func fr other xml.i want to use two nodevalues and highlight it.i tried something.but i am getting error in the line highlighted(**) as 'Object Required'.your quick reply will help me more.
Public Sub DisplayNode1(ByRef Nodes1 As MSXML2.IXMLDOMNodeList, _
ByVal Indent1 As Integer)
some lines
RichTextBox2.Text = Space$(Indent) & xNode1.ParentNode.nodeName & _
":" & xNode1.NodeValue
difference
some lines
Public Sub difference()
Dim a As IXMLDOMText
Dim b As IXMLDOMText
a.NodeValue = xNode.innertext 'i get erroe in line
b.NodeValue = xNode1.innertext
If StrComp(a, b) > 0 Then
a = vbRed
b = vbRed
End If
please help me soon.
There is a lot that is potentially wrong with this.
xnode isn't declared anywhere in your code sample
Neither a, b, or xnode are explicitly set anywhere in your code sample
Unless xnode is a form/module/global level variable then it will be out of scope in the Difference procedure
It's not shown but I'm guessing that you don't have Option Explicit set in your code or by default
You'll need to address these points first before you can get anywhere with this code.

Resources