ValueError : invalid literal for int() with base 10:installing numpy for python 3.1.2 on Ubuntu 10.04How to...
What is the most fuel efficient way out of the Solar System?
In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?
Why did the villain in the first Men in Black movie care about Earth's Cockroaches?
A starship is travelling at 0.9c and collides with a small rock. Will it leave a clean hole through, or will more happen?
Making him into a bully (how to show mild violence)
Do authors have to be politically correct in article-writing?
Why avoid shared user accounts?
How do I append a character to the end of every line in an Excel cell?
Cookies - Should the toggles be on?
Why are the books in the Game of Thrones citadel library shelved spine inwards?
Is a new Boolean field better than a null reference when a value can be meaningfully absent?
Can a hotel cancel a confirmed reservation?
How does Leonard in "Memento" remember reading and writing?
What is the purpose of easy combat scenarios that don't need resource expenditure?
Why am I able to open Wireshark and capture packets in macOS without root privileges?
Is it a fallacy if someone claims they need an explanation for every word of your argument to the point where they don't understand common terms?
How can a school be getting an epidemic of whooping cough if most of the students are vaccinated?
What is the wife of a henpecked husband called?
Quickly creating a sparse array
Should I reinstall Linux when changing the laptop's CPU?
What incentives do banks have to gather up loans into pools (backed by Ginnie Mae)and selling them?
Removing disk while game is suspended
Can I make estimated tax payments instead of withholding from my paycheck?
How much mayhem could I cause as a sentient fish?
ValueError : invalid literal for int() with base 10:
installing numpy for python 3.1.2 on Ubuntu 10.04How to create a virtualenv with Python3.3 in Ubuntu?Install Nibabel for Python 3virtualenvwrapper + python3: invalid syntaxHow to install firefoxdriver webdriver for python3 selenium on ubuntu?How to setup VIM with python3 and YouCompleteMe in virtualenvpip fails with ReadTimeoutErrorNumpy installed only for python3.5, not for python3.6Installing pip for python 3.5mujoco-py binary file for arm64
This is my code. This is to male dictionary. My input file id data1 which is latex file of academic paper.when i run these i'm getting the error
ValueError : invalid literal for int() with base 10:
and when i call the writeFile() Then i am getting
label = self.idxToLabel[i]
KeyError: 0
import torch
PAD = 0
UNK = 1
BOS = 2
EOS = 3
PAD_WORD = '<blank>'
UNK_WORD = 'UNK'
BOS_WORD = '<s>'
EOS_WORD = '</s>'
SPA_WORD = ' '
def flatten(l):
for el in l:
if hasattr(el, "__iter__"):
for sub in flatten(el):
yield sub
else:
yield el
class Dict(object):
def __init__(self, data=None, lower=False):
self.idxToLabel = {}
self.labelToIdx = {}
self.frequencies = {}
self.lower = lower
# Special entries will not be pruned.
self.special = []
if data is not None:
if type(data) == str:
self.loadFile(data)
else:
self.addSpecials(data)
def size(self):
return len(self.idxToLabel)
# Load entries from a file.
def loadFile(self, filename):
print(filename)
for line in open(filename):
fields = line.split()
print('fields',fields)
label = ' '.join(fields[:-1])
print('label',label)
print(fields[-1])
idx =int(fields[-1])
type(idx)
print("idx",idx)
self.add(label, idx)
# Write entries to a file.
def writeFile(self, filename):
with open(filename, 'w') as file:
for i in range(self.size()):
label = self.idxToLabel[i]
print("label",label)
file.write('%s %dn' % (label, i))
file.close()
def loadDict(self, idxToLabel):
for i in range(len(idxToLabel)):
#print(len(idxToLabel))
label = idxToLabel[i]
self.add(label, i)
def lookup(self, key, default=None):
key = key.lower() if self.lower else key
try:
return self.labelToIdx[key]
except KeyError:
return default
def getLabel(self, idx, default=None):
try:
return self.idxToLabel[idx]
except KeyError:
return default
# Mark this `label` and `idx` as special (i.e. will not be pruned).
def addSpecial(self, label, idx=None):
idx = self.add(label, idx)
self.special += [idx]
# Mark all labels in `labels` as specials (i.e. will not be pruned).
def addSpecials(self, labels):
for label in labels:
self.addSpecial(label)
# Add `label` in the dictionary. Use `idx` as its index if given.
def add(self, label, idx=None):
label = label.lower() if self.lower else label
if idx is not None:
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
else:
if label in self.labelToIdx:
idx = self.labelToIdx[label]
else:
idx = len(self.idxToLabel)
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
if idx not in self.frequencies:
self.frequencies[idx] = 1
else:
self.frequencies[idx] += 1
return idx
# Return a new dictionary with the `size` most frequent entries.
def prune(self, size):
if size >= self.size():
return self
# Only keep the `size` most frequent entries.
freq = torch.Tensor(
[self.frequencies[i] for i in range(len(self.frequencies))])
idx = torch.sort(freq, 0, True)
newDict = Dict()
newDict.lower = self.lower
# Add special entries in all cases.
for i in self.special:
newDict.addSpecial(self.idxToLabel[i])
for i in idx[:size]:
newDict.add(self.idxToLabel[i])
return newDict
# Convert `labels` to indices. Use `unkWord` if not found.
# Optionally insert `bosWord` at the beginning and `eosWord` at the .
def convertToIdx(self, labels, unkWord, bosWord=None, eosWord=None):
vec = []
if bosWord is not None:
vec += [self.lookup(bosWord)]
unk = self.lookup(unkWord)
vec += [self.lookup(label, default=unk) for label in labels]
if eosWord is not None:
vec += [self.lookup(eosWord)]
vec = [x for x in flatten(vec)]
return torch.LongTensor(vec)
# Convert `idx` to labels. If index `stop` is reached, convert it and return.
def convertToLabels(self, idx, stop):
labels = []
for i in idx:
if i == stop:
break
labels += [self.getLabel(i)]
return labels
tmp=Dict('D:/AAPR-master/AAPR_Dataset/data1')
python3
add a comment |
This is my code. This is to male dictionary. My input file id data1 which is latex file of academic paper.when i run these i'm getting the error
ValueError : invalid literal for int() with base 10:
and when i call the writeFile() Then i am getting
label = self.idxToLabel[i]
KeyError: 0
import torch
PAD = 0
UNK = 1
BOS = 2
EOS = 3
PAD_WORD = '<blank>'
UNK_WORD = 'UNK'
BOS_WORD = '<s>'
EOS_WORD = '</s>'
SPA_WORD = ' '
def flatten(l):
for el in l:
if hasattr(el, "__iter__"):
for sub in flatten(el):
yield sub
else:
yield el
class Dict(object):
def __init__(self, data=None, lower=False):
self.idxToLabel = {}
self.labelToIdx = {}
self.frequencies = {}
self.lower = lower
# Special entries will not be pruned.
self.special = []
if data is not None:
if type(data) == str:
self.loadFile(data)
else:
self.addSpecials(data)
def size(self):
return len(self.idxToLabel)
# Load entries from a file.
def loadFile(self, filename):
print(filename)
for line in open(filename):
fields = line.split()
print('fields',fields)
label = ' '.join(fields[:-1])
print('label',label)
print(fields[-1])
idx =int(fields[-1])
type(idx)
print("idx",idx)
self.add(label, idx)
# Write entries to a file.
def writeFile(self, filename):
with open(filename, 'w') as file:
for i in range(self.size()):
label = self.idxToLabel[i]
print("label",label)
file.write('%s %dn' % (label, i))
file.close()
def loadDict(self, idxToLabel):
for i in range(len(idxToLabel)):
#print(len(idxToLabel))
label = idxToLabel[i]
self.add(label, i)
def lookup(self, key, default=None):
key = key.lower() if self.lower else key
try:
return self.labelToIdx[key]
except KeyError:
return default
def getLabel(self, idx, default=None):
try:
return self.idxToLabel[idx]
except KeyError:
return default
# Mark this `label` and `idx` as special (i.e. will not be pruned).
def addSpecial(self, label, idx=None):
idx = self.add(label, idx)
self.special += [idx]
# Mark all labels in `labels` as specials (i.e. will not be pruned).
def addSpecials(self, labels):
for label in labels:
self.addSpecial(label)
# Add `label` in the dictionary. Use `idx` as its index if given.
def add(self, label, idx=None):
label = label.lower() if self.lower else label
if idx is not None:
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
else:
if label in self.labelToIdx:
idx = self.labelToIdx[label]
else:
idx = len(self.idxToLabel)
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
if idx not in self.frequencies:
self.frequencies[idx] = 1
else:
self.frequencies[idx] += 1
return idx
# Return a new dictionary with the `size` most frequent entries.
def prune(self, size):
if size >= self.size():
return self
# Only keep the `size` most frequent entries.
freq = torch.Tensor(
[self.frequencies[i] for i in range(len(self.frequencies))])
idx = torch.sort(freq, 0, True)
newDict = Dict()
newDict.lower = self.lower
# Add special entries in all cases.
for i in self.special:
newDict.addSpecial(self.idxToLabel[i])
for i in idx[:size]:
newDict.add(self.idxToLabel[i])
return newDict
# Convert `labels` to indices. Use `unkWord` if not found.
# Optionally insert `bosWord` at the beginning and `eosWord` at the .
def convertToIdx(self, labels, unkWord, bosWord=None, eosWord=None):
vec = []
if bosWord is not None:
vec += [self.lookup(bosWord)]
unk = self.lookup(unkWord)
vec += [self.lookup(label, default=unk) for label in labels]
if eosWord is not None:
vec += [self.lookup(eosWord)]
vec = [x for x in flatten(vec)]
return torch.LongTensor(vec)
# Convert `idx` to labels. If index `stop` is reached, convert it and return.
def convertToLabels(self, idx, stop):
labels = []
for i in idx:
if i == stop:
break
labels += [self.getLabel(i)]
return labels
tmp=Dict('D:/AAPR-master/AAPR_Dataset/data1')
python3
Without seeing your input we cannot help. The message means thatis\r\n",
cannot be converted to an integer, which sounds reasonable.
– PerlDuck
Feb 14 at 18:35
my input is a latex file of an academic paper
– ammu
Feb 15 at 5:14
1
Yes, but how can we help you? The code splits each input line into fields (separated by whitespace) and then tries to convert the last of these fields into an integer. The error you see means that this last field cannot be converted to an integer because it contains the stringis\r\n",
. It's like asking someone how old he is and he answersis\r\n",
. Now way to figure out the person's age from that. Please edit your post and tell us what your actual question is.
– PerlDuck
Feb 15 at 10:05
Thank you for updating the question. But still, "how to convert the last field to interger by excluding the string" What do you mean by that? What should be the integer value for the stringis\r\n",
? Please add an input line to your post and the expected output for that line.
– PerlDuck
Feb 16 at 15:17
add a comment |
This is my code. This is to male dictionary. My input file id data1 which is latex file of academic paper.when i run these i'm getting the error
ValueError : invalid literal for int() with base 10:
and when i call the writeFile() Then i am getting
label = self.idxToLabel[i]
KeyError: 0
import torch
PAD = 0
UNK = 1
BOS = 2
EOS = 3
PAD_WORD = '<blank>'
UNK_WORD = 'UNK'
BOS_WORD = '<s>'
EOS_WORD = '</s>'
SPA_WORD = ' '
def flatten(l):
for el in l:
if hasattr(el, "__iter__"):
for sub in flatten(el):
yield sub
else:
yield el
class Dict(object):
def __init__(self, data=None, lower=False):
self.idxToLabel = {}
self.labelToIdx = {}
self.frequencies = {}
self.lower = lower
# Special entries will not be pruned.
self.special = []
if data is not None:
if type(data) == str:
self.loadFile(data)
else:
self.addSpecials(data)
def size(self):
return len(self.idxToLabel)
# Load entries from a file.
def loadFile(self, filename):
print(filename)
for line in open(filename):
fields = line.split()
print('fields',fields)
label = ' '.join(fields[:-1])
print('label',label)
print(fields[-1])
idx =int(fields[-1])
type(idx)
print("idx",idx)
self.add(label, idx)
# Write entries to a file.
def writeFile(self, filename):
with open(filename, 'w') as file:
for i in range(self.size()):
label = self.idxToLabel[i]
print("label",label)
file.write('%s %dn' % (label, i))
file.close()
def loadDict(self, idxToLabel):
for i in range(len(idxToLabel)):
#print(len(idxToLabel))
label = idxToLabel[i]
self.add(label, i)
def lookup(self, key, default=None):
key = key.lower() if self.lower else key
try:
return self.labelToIdx[key]
except KeyError:
return default
def getLabel(self, idx, default=None):
try:
return self.idxToLabel[idx]
except KeyError:
return default
# Mark this `label` and `idx` as special (i.e. will not be pruned).
def addSpecial(self, label, idx=None):
idx = self.add(label, idx)
self.special += [idx]
# Mark all labels in `labels` as specials (i.e. will not be pruned).
def addSpecials(self, labels):
for label in labels:
self.addSpecial(label)
# Add `label` in the dictionary. Use `idx` as its index if given.
def add(self, label, idx=None):
label = label.lower() if self.lower else label
if idx is not None:
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
else:
if label in self.labelToIdx:
idx = self.labelToIdx[label]
else:
idx = len(self.idxToLabel)
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
if idx not in self.frequencies:
self.frequencies[idx] = 1
else:
self.frequencies[idx] += 1
return idx
# Return a new dictionary with the `size` most frequent entries.
def prune(self, size):
if size >= self.size():
return self
# Only keep the `size` most frequent entries.
freq = torch.Tensor(
[self.frequencies[i] for i in range(len(self.frequencies))])
idx = torch.sort(freq, 0, True)
newDict = Dict()
newDict.lower = self.lower
# Add special entries in all cases.
for i in self.special:
newDict.addSpecial(self.idxToLabel[i])
for i in idx[:size]:
newDict.add(self.idxToLabel[i])
return newDict
# Convert `labels` to indices. Use `unkWord` if not found.
# Optionally insert `bosWord` at the beginning and `eosWord` at the .
def convertToIdx(self, labels, unkWord, bosWord=None, eosWord=None):
vec = []
if bosWord is not None:
vec += [self.lookup(bosWord)]
unk = self.lookup(unkWord)
vec += [self.lookup(label, default=unk) for label in labels]
if eosWord is not None:
vec += [self.lookup(eosWord)]
vec = [x for x in flatten(vec)]
return torch.LongTensor(vec)
# Convert `idx` to labels. If index `stop` is reached, convert it and return.
def convertToLabels(self, idx, stop):
labels = []
for i in idx:
if i == stop:
break
labels += [self.getLabel(i)]
return labels
tmp=Dict('D:/AAPR-master/AAPR_Dataset/data1')
python3
This is my code. This is to male dictionary. My input file id data1 which is latex file of academic paper.when i run these i'm getting the error
ValueError : invalid literal for int() with base 10:
and when i call the writeFile() Then i am getting
label = self.idxToLabel[i]
KeyError: 0
import torch
PAD = 0
UNK = 1
BOS = 2
EOS = 3
PAD_WORD = '<blank>'
UNK_WORD = 'UNK'
BOS_WORD = '<s>'
EOS_WORD = '</s>'
SPA_WORD = ' '
def flatten(l):
for el in l:
if hasattr(el, "__iter__"):
for sub in flatten(el):
yield sub
else:
yield el
class Dict(object):
def __init__(self, data=None, lower=False):
self.idxToLabel = {}
self.labelToIdx = {}
self.frequencies = {}
self.lower = lower
# Special entries will not be pruned.
self.special = []
if data is not None:
if type(data) == str:
self.loadFile(data)
else:
self.addSpecials(data)
def size(self):
return len(self.idxToLabel)
# Load entries from a file.
def loadFile(self, filename):
print(filename)
for line in open(filename):
fields = line.split()
print('fields',fields)
label = ' '.join(fields[:-1])
print('label',label)
print(fields[-1])
idx =int(fields[-1])
type(idx)
print("idx",idx)
self.add(label, idx)
# Write entries to a file.
def writeFile(self, filename):
with open(filename, 'w') as file:
for i in range(self.size()):
label = self.idxToLabel[i]
print("label",label)
file.write('%s %dn' % (label, i))
file.close()
def loadDict(self, idxToLabel):
for i in range(len(idxToLabel)):
#print(len(idxToLabel))
label = idxToLabel[i]
self.add(label, i)
def lookup(self, key, default=None):
key = key.lower() if self.lower else key
try:
return self.labelToIdx[key]
except KeyError:
return default
def getLabel(self, idx, default=None):
try:
return self.idxToLabel[idx]
except KeyError:
return default
# Mark this `label` and `idx` as special (i.e. will not be pruned).
def addSpecial(self, label, idx=None):
idx = self.add(label, idx)
self.special += [idx]
# Mark all labels in `labels` as specials (i.e. will not be pruned).
def addSpecials(self, labels):
for label in labels:
self.addSpecial(label)
# Add `label` in the dictionary. Use `idx` as its index if given.
def add(self, label, idx=None):
label = label.lower() if self.lower else label
if idx is not None:
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
else:
if label in self.labelToIdx:
idx = self.labelToIdx[label]
else:
idx = len(self.idxToLabel)
self.idxToLabel[idx] = label
self.labelToIdx[label] = idx
if idx not in self.frequencies:
self.frequencies[idx] = 1
else:
self.frequencies[idx] += 1
return idx
# Return a new dictionary with the `size` most frequent entries.
def prune(self, size):
if size >= self.size():
return self
# Only keep the `size` most frequent entries.
freq = torch.Tensor(
[self.frequencies[i] for i in range(len(self.frequencies))])
idx = torch.sort(freq, 0, True)
newDict = Dict()
newDict.lower = self.lower
# Add special entries in all cases.
for i in self.special:
newDict.addSpecial(self.idxToLabel[i])
for i in idx[:size]:
newDict.add(self.idxToLabel[i])
return newDict
# Convert `labels` to indices. Use `unkWord` if not found.
# Optionally insert `bosWord` at the beginning and `eosWord` at the .
def convertToIdx(self, labels, unkWord, bosWord=None, eosWord=None):
vec = []
if bosWord is not None:
vec += [self.lookup(bosWord)]
unk = self.lookup(unkWord)
vec += [self.lookup(label, default=unk) for label in labels]
if eosWord is not None:
vec += [self.lookup(eosWord)]
vec = [x for x in flatten(vec)]
return torch.LongTensor(vec)
# Convert `idx` to labels. If index `stop` is reached, convert it and return.
def convertToLabels(self, idx, stop):
labels = []
for i in idx:
if i == stop:
break
labels += [self.getLabel(i)]
return labels
tmp=Dict('D:/AAPR-master/AAPR_Dataset/data1')
python3
python3
edited 12 secs ago
ammu
asked Feb 14 at 17:51
ammuammu
314
314
Without seeing your input we cannot help. The message means thatis\r\n",
cannot be converted to an integer, which sounds reasonable.
– PerlDuck
Feb 14 at 18:35
my input is a latex file of an academic paper
– ammu
Feb 15 at 5:14
1
Yes, but how can we help you? The code splits each input line into fields (separated by whitespace) and then tries to convert the last of these fields into an integer. The error you see means that this last field cannot be converted to an integer because it contains the stringis\r\n",
. It's like asking someone how old he is and he answersis\r\n",
. Now way to figure out the person's age from that. Please edit your post and tell us what your actual question is.
– PerlDuck
Feb 15 at 10:05
Thank you for updating the question. But still, "how to convert the last field to interger by excluding the string" What do you mean by that? What should be the integer value for the stringis\r\n",
? Please add an input line to your post and the expected output for that line.
– PerlDuck
Feb 16 at 15:17
add a comment |
Without seeing your input we cannot help. The message means thatis\r\n",
cannot be converted to an integer, which sounds reasonable.
– PerlDuck
Feb 14 at 18:35
my input is a latex file of an academic paper
– ammu
Feb 15 at 5:14
1
Yes, but how can we help you? The code splits each input line into fields (separated by whitespace) and then tries to convert the last of these fields into an integer. The error you see means that this last field cannot be converted to an integer because it contains the stringis\r\n",
. It's like asking someone how old he is and he answersis\r\n",
. Now way to figure out the person's age from that. Please edit your post and tell us what your actual question is.
– PerlDuck
Feb 15 at 10:05
Thank you for updating the question. But still, "how to convert the last field to interger by excluding the string" What do you mean by that? What should be the integer value for the stringis\r\n",
? Please add an input line to your post and the expected output for that line.
– PerlDuck
Feb 16 at 15:17
Without seeing your input we cannot help. The message means that
is\r\n",
cannot be converted to an integer, which sounds reasonable.– PerlDuck
Feb 14 at 18:35
Without seeing your input we cannot help. The message means that
is\r\n",
cannot be converted to an integer, which sounds reasonable.– PerlDuck
Feb 14 at 18:35
my input is a latex file of an academic paper
– ammu
Feb 15 at 5:14
my input is a latex file of an academic paper
– ammu
Feb 15 at 5:14
1
1
Yes, but how can we help you? The code splits each input line into fields (separated by whitespace) and then tries to convert the last of these fields into an integer. The error you see means that this last field cannot be converted to an integer because it contains the string
is\r\n",
. It's like asking someone how old he is and he answers is\r\n",
. Now way to figure out the person's age from that. Please edit your post and tell us what your actual question is.– PerlDuck
Feb 15 at 10:05
Yes, but how can we help you? The code splits each input line into fields (separated by whitespace) and then tries to convert the last of these fields into an integer. The error you see means that this last field cannot be converted to an integer because it contains the string
is\r\n",
. It's like asking someone how old he is and he answers is\r\n",
. Now way to figure out the person's age from that. Please edit your post and tell us what your actual question is.– PerlDuck
Feb 15 at 10:05
Thank you for updating the question. But still, "how to convert the last field to interger by excluding the string" What do you mean by that? What should be the integer value for the string
is\r\n",
? Please add an input line to your post and the expected output for that line.– PerlDuck
Feb 16 at 15:17
Thank you for updating the question. But still, "how to convert the last field to interger by excluding the string" What do you mean by that? What should be the integer value for the string
is\r\n",
? Please add an input line to your post and the expected output for that line.– PerlDuck
Feb 16 at 15:17
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1118280%2fvalueerror-invalid-literal-for-int-with-base-10%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1118280%2fvalueerror-invalid-literal-for-int-with-base-10%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Without seeing your input we cannot help. The message means that
is\r\n",
cannot be converted to an integer, which sounds reasonable.– PerlDuck
Feb 14 at 18:35
my input is a latex file of an academic paper
– ammu
Feb 15 at 5:14
1
Yes, but how can we help you? The code splits each input line into fields (separated by whitespace) and then tries to convert the last of these fields into an integer. The error you see means that this last field cannot be converted to an integer because it contains the string
is\r\n",
. It's like asking someone how old he is and he answersis\r\n",
. Now way to figure out the person's age from that. Please edit your post and tell us what your actual question is.– PerlDuck
Feb 15 at 10:05
Thank you for updating the question. But still, "how to convert the last field to interger by excluding the string" What do you mean by that? What should be the integer value for the string
is\r\n",
? Please add an input line to your post and the expected output for that line.– PerlDuck
Feb 16 at 15:17